An anti-join finds rows with no match
Sometimes the question is who is missing: which customers have never ordered? Start with a LEFT JOIN so every customer stays, even with no order. Customers with no match get NULL in every orders column. Then keep only those rows with WHERE orders.id IS NULL. That pattern — LEFT JOIN plus IS NULL on the other table’s key — is called an anti-join.
A tiny example
In plain English: Show me the customers who have not placed any orders.
SELECT c.name
FROM customers c
LEFT JOIN orders o
ON o.customer_id = c.id
WHERE o.id IS NULL;Query result
| name |
|---|
| Sana |
Sana matched no order, so her orders columns were NULL and the WHERE test kept only her.
See every JOIN type side by side in the SQL JOIN diagram & cheat sheet.
Related SQL lessons
Ready for a break?
A fresh, bite-sized SQL puzzle waits every morning. Tap tiles, see real results. No terminal, no setup, no timers.
Try today's free SQL puzzle