Watch LEFT JOIN preserve every row of A while filling unmatched B columns with NULL. Includes the classic WHERE-clause trap explained visually.
Join type
Data (click a cell to edit)
SELECT * FROM A LEFT JOIN B ON A.key = B.key
ON A.key = B.key — empty keys are treated as SQL NULL and never match
Table A
Table B
Result
| A.key | A.val | B.key | B.val |
|---|---|---|---|
| 1 | kim | 1 | dev |
| 3 | park | 3 | hr |
| 2 | lee | NULL | NULL |
Edit a key or add a row — the connector lines and result update instantly. The 'Duplicate key' preset shows why LEFT JOIN row counts can grow.
LEFT JOIN preserves every row of the left table (A) and fills unmatched B columns with NULL — the standard pattern for 'all users, with their orders if they have any'.
The classic trap is the WHERE clause: `WHERE B.col = 'x'` after a LEFT JOIN filters out the NULL-B rows, silently turning it into an INNER JOIN. Move the condition to ON.
The result has at least as many rows as A. Multiple matches duplicate the A row, so LEFT JOIN is also a common source of inflated aggregates. SQL JOIN Visualizer