I see people using LEFT JOIN in their mysql queries to fetch data from two tables. But I normally do it without left joi开发者_运维技巧n. Is there any differences besides the syntax, e.g. performance?
Here's my normal query style:
SELECT * FROM table1 as tbl1, table2 as tbl2 WHERE tbl1.id=tbl2.table_id
as compared to
SELECT * FROM table1 as tbl1 LEFT JOIN table2 as tbl2 on tbl1.id=tbl2.id
Personally I prefer the first style...hmm..
On a left join, all values from table1 are selected even if table2 does not contain the same id.
Your normal query style can be compared to an "inner join".
精彩评论