LEFT JOIN

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

keyval

Table B

keyval
Matched rowsRows only in ARows only in B

Result

Result rows: 3Matched: 2A only: 1B only: 0
A.keyA.valB.keyB.val
1kim1dev
3park3hr
2leeNULLNULL

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

Frequently asked questions

Why am I not seeing NULL rows in my LEFT JOIN?
A WHERE condition on a B column filtered them out, making it behave like INNER JOIN. Move that condition to the ON clause.
Is LEFT JOIN different from LEFT OUTER JOIN?
Identical — OUTER is an optional keyword. Same for RIGHT and FULL.
How do I get only the unmatched A rows?
LEFT JOIN plus WHERE B.key IS NULL — the anti-join. Select 'LEFT ONLY' in this tool to see exactly that result.

Other joins