I’ve got the following request :
select * from tbA A, tbB B, tbC C, tbD D where A.ID=B.ID and B.ID2= C.ID2 and A.ID=D.ID and C.ID3=D.ID3 and B.ID4=D.ID4 and A.Foo='Foo'
I’ve heard several times that this join syntax is depreciated, and that I should use the ‘JOIN’ keyword instead.
How do I do that in such a complicated join (multiple tables joined on multiple columns belonging to different tables)? Do you think this best practice still applies here ?
It’s a matter of taste, but I like the JOIN keyword better. It makes the logic clearer and is more consistent with the LEFT OUTER JOIN syntax that goes with it. Note that you can also use INNER JOIN which is synonymous with JOIN.
The syntax is
b can be a join itself. For inner joins it doesn’t matter, but for outer you can control the order of the joins like this:
Here a is left-joined to the inner join between d and c.
Here is your query: