Loading…
LEFT JOIN includes ALL rows from the left table, even if there's no match in the right table. Unmatched rows get NULL values.| Type | What it returns |
|---|---|
| <code>INNER JOIN</code> | Only rows that match in BOTH tables |
| <code>LEFT JOIN</code> | ALL rows from the left table + matches from right |
INNER JOIN (customers → orders):
| Customer | Order |
|---|---|
| Alice | Order 1 |
| Bob | Order 2 |
| ~~Carol~~ | ~~(no orders — excluded!)~~ |
| Customer | Order |
|---|---|
| Alice | Order 1 |
| Bob | Order 2 |
| Carol ✅ | NULL (no orders — still included!) |
SELECT c.name, o.id
FROM customers c
LEFT JOIN orders o ON c.id = o.customer_id;
The left table (customers, written after FROM) keeps all its rows.
Find all customers and their orders (including customers with no orders).
Downloading SQL engine… (one-time)
This runs entirely in your browser and is cached for next time.