Reputation: 10139
When using SQL to access 2 tables, I usually do something like this:
SELECT table1.id, table1.name, table2.value
FROM table1 JOIN table2 ON table1.table2_id = table2.id
WHERE table1.name LIKE 'abc%'
Using a join
to connect the two tables.
However in a project I have taken over I keep encountering this approach:
SELECT table1.id, table1.name, table2.value
FROM table1 as t1, table2 as t2
WHERE t1.table2_id = t2.id AND table1.name LIKE 'abc%'
Where the tables are not joined, but connected together in the where
statement.
In what situations is this approach better than joining
the two tables?
Upvotes: 1
Views: 47
Reputation: 1150
The multiple select was the older way and JOINs are new way to do same thing. The syntax is different but the performance looks same. As the optimizer do multiple select replaced with JOIN syntax.
Below is reference you can find helpful: Multiple Table Select vs. JOIN (performance)
Upvotes: 1