A condition placed in the ON clause controls which rows from the joined table are considered matches.
For OUTER JOINs, filtering in ON can preserve unmatched rows while restricting the related records.
Show every customer but only orders above ₹10,000.
SELECT
c.CustomerName,
o.OrderID,
o.OrderAmount
FROM Customers c
LEFT JOIN Orders o
ON c.CustomerID = o.CustomerID
AND o.OrderAmount > 10000;
Used in customer reporting, financial analysis, transaction filtering, and dashboard queries.
- ON controls matching logic.
- LEFT JOIN still preserves customers without matching orders.
- The filter affects only the right-side matches.
- This differs from putting the same condition in WHERE.
- Useful for conditional OUTER JOINs.
What happens when a filter is placed in ON?
It restricts which rows qualify as matches during the JOIN.
Why is this useful with LEFT JOIN?
It can filter related rows while still preserving unmatched rows from the left table.