Condition in ON or in WHERE

In an outer join, a condition placed in ON limits the matches without removing rows from the preserved table, whereas a condition on the right table placed in WHERE eliminates the NULL rows and effectively turns the join into an INNER JOIN. For an INNER JOIN, both placements are equivalent.

Example

LEFT JOIN commandes o ON o.client_id = c.id AND o.annee = 2025

Related concepts

The whole glossary