Skip to content
Home » Survey: Join Predicate Order

Survey: Join Predicate Order

  • by

It’s a quiet month as we look forward to 2016, so I’m asking a series of survey questions for the next few posts.

My first one is about the order of join predicates.

When joining two or more tables in T-SQL, which do you prefer?

SELECT *
FROM TableA a
INNER JOIN TableB b
   ON a.Col1 = b.Col1

or

SELECT *
FROM TableA a
INNER JOIN TableB b
   ON b.Col1 = a.Col1

The SQL Server Query Optimizer doesn’t care, so it comes down to your preference.

For legibility, I prefer the first option, where the table order is reflected in the predicate order.

Some people like having the order reversed.

Which do you prefer, and why?