A plain JOIN keeps only the rows that find a match. That's a problem when you want a full list: a customer who never ordered has no matching order, so that customer vanishes from the result. A LEFT JOIN keeps every row of the left table, the one in FROM, even when the right table has nothing for it.
When nothing matches, the right table's columns are filled with NULL. For example, this query lists every product with the quantities it was ordered in, and a product nobody ordered still appears once, with NULL as its quantity:
SELECT products.name, order_items.quantity
FROM products
LEFT JOIN order_items
ON order_items.product_id = products.id
The ON rule works as in an ordinary join. A customer with two orders gets two rows; a customer with none gets one row, with NULL in the order's columns.
Your query lists each customer with the id and date of each of their orders. The check prints:
name | id | ordered
Ana Pop | 1 | 2026-03-02
Ana Pop | 3 | 2026-04-05
Ben Ortiz | 2 | 2026-03-15
Ben Ortiz | 6 | 2026-05-21
Chloe Ng | 4 | 2026-04-18
Chloe Ng | 7 | 2026-05-30
Dan Weber | 5 | 2026-05-07
Eva Rossi | NULL | NULL
(8 rows)
Your task: select customers.name, orders.id and orders.ordered from customers, LEFT JOIN the orders, and match the rows with ON: the order's customer_id equals the customer's id.
Assignment
Follow the Coding Tutorial to list every customer with their orders, including Eva Rossi, who has none.
Hint
The table in FROM is the one whose rows are all kept, so start from customers. Without ON you get 35 rows: every customer with every order.
Free plan: 30 tutor messages. PRO is unlimited.
