How sql server evaluates the multiple different joins?

Posted by ziang on Stack Overflow See other posts from Stack Overflow or by ziang
Published on 2010-03-31T15:58:08Z Indexed on 2010/03/31 16:13 UTC
Read the original article Hit count: 262

Hi, i have a general question about how sql server evaluates the joins.The query is

SELECT * 
FROM TableA 
 INNER JOIN TableB ON TableB.id = TableA.id
 LEFT JOIN TABLEC ON TABLEC.id = TABLEB.id

Q1: What tables is the left join based on? I know it will based on the TABLEC but what is the other one? Is it the result of the first inner join or the TABLEB specified in the left join condition?

Q2: Is "LEFT JOIN TABLEC ON TABLEC.id = TABLEB.id" equivalent to "LEFT JOIN TABLEC ON TABLEB.id = TABLEC.id"

Q3: Is the query equivalent to the following one? (with TABLEB.id replaced by TABLEA.id?)

SELECT * 
FROM TableA 
 INNER JOIN TableB ON TableB.id = TableA.id
 LEFT JOIN TABLEC ON TABLEC.id = TABLEA.id

Thank you!

© Stack Overflow or respective owner

Related posts about sql-server-2008

Related posts about left-join