views:

24

answers:

1

Hi,

I see people using LEFT JOIN in their mysql queries to fetch data from two tables. But I normally do it without left join. 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..

+2  A: 

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".

deltreme
so assuming if i was comparing the normal style query and one that uses inner join, is there any difference or reason why I should use one over the other? thanks :)
Lyon