UPDATESQL

Unit 10 · LEFT JOIN, NULL

Finding missing matches with LEFT JOIN

Customers who never ordered

A LEFT JOIN keeps every row from the left table, matched or not. Where there is no match, the right table's columns come back as NULL, which makes "find what is missing" questions easy.

Example
SELECT p.name
FROM products p
LEFT JOIN order_items oi ON oi.product_id = p.id
WHERE oi.product_id IS NULL;

Your task

Some people signed up and never bought anything. Find every customer with zero orders so the team can send them a first-order offer.

Tables you will use: customers, orders

Try it in your browserFree, no sign-up. Your query is checked as you go.