RIGHT JOIN

See RIGHT JOIN preserve every row of B while filling unmatched A columns with NULL — and why it's just LEFT JOIN with the tables swapped.

Join type

Data (click a cell to edit)

SELECT * FROM A
RIGHT 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: 0B only: 1
A.keyA.valB.keyB.val
1kim1dev
3park3hr
NULLNULL4fin

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.

RIGHT JOIN preserves every row of the right table (B) and fills unmatched A columns with NULL — the mirror image of LEFT JOIN.

A RIGHT JOIN B is exactly B LEFT JOIN A. Most teams standardize on LEFT JOIN for readability, and some ORMs cannot even generate RIGHT JOIN.

RIGHT JOIN earns its place when the driving table happens to be on the right — reordering a chain of joins around it can simplify the query. SQL JOIN Visualizer

Frequently asked questions

Is RIGHT JOIN ever necessary?
Logically no — it can always be rewritten as LEFT JOIN with swapped tables. Sometimes it simply reads more naturally.
Is RIGHT JOIN slower than LEFT JOIN?
No. The optimizer produces the same plan — the choice is purely about readability.

Other joins