I have come across several stored procedures in our "legacy" code that have joins that look like this:
SELECT *
FROM TableA
INNER JOIN TableB
INNER JOIN TableC ON TableC.TableBId = TableB.TableBId
ON TableA.TableAId = TableB.TableAId
I would write this query differently, like this:
SELECT *
FROM TableA
INNER JOIN TableB ON TableA.TableAId = TableB.TableAId
INNER JOIN TableC ON TableB.TableBId = TableC.TableBId
The results are the same, but I find the second example to be much easier to follow, especially in situations where there are several joins. Is there any advantage to writing JOIN
statements with the ON
clause "deferred" until after all of the joins have been specified, as in the first example?