Joins: Associativity

When an operation is associative, the grouping of elements does not matter.

Addition and multiplication are both associative. You can add brackets or remove brackets. The result is always the same.

Addition

\[(1 + 2) + 3 = 6\\ 3 + (2 + 1) = 6\\\]

Multiplication

\[(3 \times 2) \times 1 = 6\\ 3 \times (2 \times 1) = 6\\\]

Associative SQL Joins

SQL Joins are associative when they are of the same type

Inner Join Only

(A INNER JOIN B) INNER JOIN C = A INNER JOIN (B INNER JOIN C) 

Left Join Only

(A LEFT JOIN B) LEFT JOIN C = A LEFT JOIN (B LEFT JOIN C)

References

http://blog.ylett.com/2011/09/non-associativity-of-sql-table-joins.html http://www.sql-tutorial.ru/en/book_explicit_join_operations/page4.html

Updated: