SQL JOIN Visualizer
Compare matching, duplicate and unmatched rows across seven JOIN examples using two synthetic tables.
Enabling local controls…
| id | code | name |
|---|---|---|
| 1 | 10 | Mira |
| 2 | 20 | Noah |
| 3 | 20 | Ren |
| 4 | 30 | Inez |
| 5 | NULL | Sol |
| id | member_code | activity |
|---|---|---|
| 101 | 10 | Design |
| 102 | 20 | SQL |
| 103 | 20 | Data |
| 104 | 40 | Systems |
| 105 | NULL | Testing |
Join on members.code = visits.member_code. Each equal non-NULL key creates one row per pair.
5 rows · 5 matched · 0 left only · 0 right only
On narrow screens, scroll the result table horizontally.
| member_id | member_code | member_name | visit_id | visit_code | visit_activity |
|---|---|---|---|---|---|
| 1 | 10 | Mira | 101 | 10 | Design |
| 2 | 20 | Noah | 102 | 20 | SQL |
| 2 | 20 | Noah | 103 | 20 | Data |
| 3 | 20 | Ren | 102 | 20 | SQL |
| 3 | 20 | Ren | 103 | 20 | Data |
Preview: first 32,000 characters. Copy, download and expanded text retain all content. Select complete text if copying fails.
SELECT m.id AS member_id, m.code AS member_code, m.name AS member_name,
v.id AS visit_id, v.member_code AS visit_code, v.activity AS visit_activity
FROM members AS m
INNER JOIN visits AS v ON m.code = v.member_code
ORDER BY CASE WHEN m.id IS NULL THEN 1 ELSE 0 END, m.id, v.id;Expand complete selectable text
SELECT m.id AS member_id, m.code AS member_code, m.name AS member_name,
v.id AS visit_id, v.member_code AS visit_code, v.activity AS visit_activity
FROM members AS m
INNER JOIN visits AS v ON m.code = v.member_code
ORDER BY CASE WHEN m.id IS NULL THEN 1 ELSE 0 END, m.id, v.id;How to use this tool
Select a join to compare the source tables and output rows. For key 20, two rows from each side produce four pairs. Equality leaves NULL keys unmatched, even when both sides contain NULL.
When not to use it
The three unmatched-only examples filter outer joins with IS NULL on a non-nullable row ID. SQLite supports RIGHT JOIN and FULL OUTER JOIN from 3.39.0. MySQL supports RIGHT JOIN and requires rewriting the two FULL OUTER JOIN examples. The page simulates the output in your browser.