SQL reference

SQL LEFT JOIN: keep rows with no match

In Excel, you'd reach for
fxVLOOKUP that keeps the #N/A rows, wrapped in IFERROR

A plain JOIN quietly drops rows that find no partner. Often those are exactly the rows you care about: customers who never ordered, products that never sold, leads nobody called.

LEFT JOIN keeps every row from the first (left) table. Where there's no match, the columns from the second table come back empty (NULL), like an #N/A you can filter on.

SQL joins Venn diagram: INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL OUTER JOIN, each with its query
The four SQL joins as Venn diagrams, each with its query. Download · Save to Pinterest

Syntax

SELECT a.col, b.col
FROM table_a a
LEFT JOIN table_b b ON b.id = a.b_id;
Try itEdit the query, then Run
namesignup_dateorder_id
Kavya Haddad2026-01-01empty
Elena Nguyen2026-01-06empty
Quinn Lopez2026-01-08empty
Sam Okafor2026-01-10empty
Ben Smith2026-01-10empty
Olivia Garcia2026-01-20empty
Carla Haddad2026-01-20empty
Arjun Patel2026-01-24empty
Dana Rossi2026-01-24empty
Umar Silva2026-01-26empty

10 rows

That WHERE o.id IS NULL is the classic "find what's missing" pattern: join, then keep only the rows where the match came back empty. These are customers with no orders.

Careful: a condition on the right-hand table in WHERE (say WHERE o.region = 'Europe') throws away the empty rows and turns your LEFT JOIN back into a plain JOIN. Put it in the ON instead: LEFT JOIN orders o ON o.customer_id = c.id AND o.region = 'Europe'.

Your turn

How many customers have no subscription? Call it never_paid.

This page on one card

SQL LEFT JOIN: keep rows with no match: the Excel way (VLOOKUP that keeps the #N/A rows) and the SQL query, side by side
SQL LEFT JOIN: keep rows with no match, on one card: the Excel way and the SQL. Download · Save to Pinterest
The practice data (7 tables)

See every column and sample rows