×

sql · level 2 · unit 3 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

LEFT JOIN plus IS NULL finds rows with no match.

Which customers have never ordered? Which dishes has nobody chosen? Questions about what is missing are some of the most useful a business can ask.

Start with a LEFT JOIN, so every customer stays. Customers with no orders get NULL in every orders column. Then WHERE o.id IS NULL keeps only those rows.

This pattern is called an . Test a column that is never empty in a real match, like the id.

SELECT c.name
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.id IS NULL;

= NULL never matches anything, so always write IS NULL.