Conor vs. Left Outer Join Reordering

A question from two of the MVPs:

Are these two queries conceptually the same?

select a.id, b.id, c.id

from A

left join C on A.id = C.id

left join B on A.id = B.id;

 

select a.id, b.id, c.id

from A

left join B on A.id = B.id

left join C on A.id = C.id;

 

Answer: YES, they are equivalent.

 

Does SQL Server consider reordering these expressions?  Also “Yes”, though you may need to do some more work to build a larger query where the order difference would matter.  So, SQL Server does not strictly execute those non-full outer joins in the order you pass them syntactically.  (This matches the general SQL Server policy of trying to make it not matter how you write the query for most normal formulations)

 

Happy Querying!

 

Conor