Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql multiple left join

Tags:

mysql

We have one table say table A we left join with table B. This works fine. The issue here is that based on the left join of table A and B we would like to have another left join but between table B and table C because those fields are available only in this 2 table so what is best solution to build this query?

like image 579
user837306 Avatar asked Jul 31 '12 05:07

user837306


1 Answers

You can chain joins quite easily:

SELECT ...
FROM a
LEFT JOIN b on a.somefield=b.somefield
LEFT JOIN c on b.otherfield=c.otherfield
like image 136
Marc B Avatar answered Oct 13 '22 23:10

Marc B