I have a problem using multiple joins in one SQL Statement. For example, I have 10 Tables which are tbl1, tbl2, tbl3,..,tbl10. I would like to select some columns from each table.
If I use joins in between, I don't know how to use Left, Right, etc. in the SQL statement from priority aspect. I mean is it organized with parentheses or something else?
Relations for example are like following:
My query is as following:
SELECT T1.col1, T2.col2, T3.col3, T4.col1 AS Expr1 FROM T1 INNER JOIN T1_T2 ON T1.id = T1_T2.T1_FK INNER JOIN T2 ON T1_T2.T2_FK = T2.id LEFT JOIN T2_T3 ON T2.id = T2_T3.T2_FK INNER JOIN T3 ON T2_T3.T3_FK = T3.id LEFT JOIN T3_T4 ON T3.id = T3_T4.T3_FK INNER JOIN T4 ON T3_T4.T4_FK = T4.id
How does SQL Server interpret the joins? Can one represent it like execution priorities with parentheses? I mean:
((T1 INNER Join T1_T2) INNER JOIN T2) LEFT JOIN T2_T3) ?