SQL Join Visualizer

Type two small tables and see exactly which rows INNER, LEFT, RIGHT, FULL and CROSS joins return.

How it works

Type two small tables as comma separated lines. The first line is the column names. Pick the columns to match and the join type. The tool shows exactly which rows come out, with NULL where there is no match.

The formula

INNER: only rows with a match on both sides
LEFT: all left rows, NULL for the right if no match
RIGHT: all right rows, NULL for the left if no match
FULL: all rows from both
CROSS: every left row with every right row (n x m)

Worked example

Users 1, 2, 3 and courses for users 1, 1 and 4. INNER JOIN gives 2 rows (user 1 twice). LEFT JOIN gives 4 rows, with users 2 and 3 showing NULL. FULL OUTER JOIN gives 5.

Good to know

Common questions

What is the difference between WHERE and ON?
For INNER JOIN nothing. For a LEFT JOIN, a filter on the right table in WHERE turns it back into an inner join.
Does MySQL have FULL OUTER JOIN?
Not directly. People use a LEFT JOIN UNION a RIGHT JOIN.
How many rows does a join return?
It can be more or fewer than either table, depending on how many matches each row has.

More in CS Labs & Coding.