Hi,
Just doing a bit of research on MySQL to pass the time. I am reading up on JOIN queries and notice that there are several ways to write the same query. Here are two examples:
Example 1:
is the same asCode:SELECT people.name, positions.name FROM test2,people,positions where people.id=test2.ID and positions.id=test2.ID
There are probably more ways to write this, but which is better or are they both pretty much the same?Code:SELECT people.name, positions.name FROM test2 JOIN people ON people.id=test2.ID JOIN positions ON positions.id=test2.ID
Example 2:
is the same asCode:select * from test1 JOIN test2 where test1.col1=test2.col3
is the same asCode:select * from test1,test2 where test1.col1=test2.col3
is the same asCode:select * from test1 JOIN test2 ON test2.col3=test1.col1
Which, if any, of the above queries, which all work, should not be used?Code:select * from test1 JOIN test2 ON test1.col1=test2.col3



Reply With Quote
Bookmarks