CROSS JOIN

CROSS JOIN pairs every row of A with every row of B — no condition. See why accidental cross joins explode row counts.

Join type

Data (click a cell to edit)

SELECT * FROM A
CROSS JOIN B

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 BMatched but excluded

Result

Result rows: 9Matched: 9A only: 0B only: 0
A.keyA.valB.keyB.val
1kim1dev
1kim3hr
1kim4fin
2lee1dev
2lee3hr
2lee4fin
3park1dev
3park3hr
3park4fin

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.

CROSS JOIN produces every combination: A × B rows, no condition. Five rows times a hundred rows is five hundred result rows.

Legitimate uses are 'generate all combinations' — date × product grids that fill empty cells with zero sales, or color × size SKU matrices.

The danger is the accidental one: `FROM A, B` without a join condition is a cross join in disguise, and it's how production queries suddenly return hundreds of thousands of rows. SQL JOIN Visualizer

Frequently asked questions

How does CROSS JOIN relate to INNER JOIN?
CROSS JOIN plus a WHERE condition equals INNER JOIN — many databases actually optimize ON joins as 'cross product + filter'.
Is FROM A, B the same as CROSS JOIN?
Yes — the comma is implicit syntax for CROSS JOIN. Prefer the explicit keyword so missing join conditions are visible.
My CROSS JOIN result is huge — how do I shrink it?
Filter each side with WHERE (or subqueries) before crossing — the product itself cannot be reduced.

Other joins