SELECT *
FROM TAB1
LEFT JOIN TAB2 ON TAB2.ID_TAB1 = TAB1.ID
JOIN TAB3 ON TAB3.ID = TAB2.ID_TAB3;
and
SELECT *
FROM TAB1
LEFT JOIN (SELECT *
FROM TAB2
JOIN TAB3 ON TAB3.ID = TAB2.ID_TAB3) T
ON T.ID_TAB1 = TAB1.ID;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, they are different – the inner join to TAB3 (after the left join to TAB2) in the first query effectively turns the left join back into an inner join.
The brackets in the second query ensure that the inner join to TAB3 is evaluated before the left join – so it remains a left join to TAB2, returning only those TAB2 records where there is a corresponding TAB3 record (otherwise, the TAB1 records are returned with corresponding NULLs).