SELECT * FROM TableA
INNER JOIN TableB
ON TableA.name = TableB.name
SELECT * FROM TableA, TableB
where TableA.name = TableB.name
Which is the preferred way and why?
Will there be any performance difference when keywords like JOIN is used?
Thanks
The second way is the classical way of doing it, from before the
joinkeyword existed.Normally the query processor generates the same database operations from the two queries, so there would be no difference in performance.
Using
joinbetter describes what you are doing in the query. If you have many joins, it’s also better because the joined table and it’s condition are beside each other, instead of putting all tables in one place and all conditions in another.Another aspect is that it’s easier to do an unbounded join by mistake using the second way, resulting in a cross join containing all combinations from the two tables.