SQL CROSS JOIN Explained: Cartesian Products Without Surprises
By Sharon Ben-Moshe · August 21, 2026 · 2 min read
Sharon Ben-Moshe is the founder of sqlfmt, a browser-based SQL formatter and validator with misspelled-keyword suggestions across PostgreSQL, MySQL, SQLite, SQL Server, and BigQuery.
A SQL CROSS JOIN returns every row combination from two inputs. Learn valid use cases, row-count math, safe formatting, and common mistakes.
Quick answer
SQL CROSS JOIN returns the Cartesian product of two inputs: every left-side row paired with every right-side row. If one input has 12 rows and the other has 3, the result has 36 rows before later filtering. Use it only when every combination is intentional.
FAQs
What is a CROSS JOIN in SQL?
A CROSS JOIN returns every combination of one row from the left input and one row from the right input. It does not use an ON matching condition.
How many rows does a CROSS JOIN return?
Before later filtering, a CROSS JOIN returns the product of its input row counts. A 12-row input crossed with a 3-row input returns 36 rows.
Is CROSS JOIN the same as INNER JOIN?
No. An INNER JOIN uses a matching condition to return related row pairs. CROSS JOIN intentionally returns every possible pair, including pairs with no relationship.
When is a CROSS JOIN useful?
CROSS JOIN is useful for deliberate combination grids, such as every reporting month by every region, and for other tasks where all pairs are required. Keep inputs bounded and review the expected row count.
Keep reading
SQL BETWEEN Is Inclusive: Safer Date Range Queries
By Sharon Ben-Moshe · Aug 21, 2026
SQL BETWEEN includes both endpoints. Learn the timestamp boundary trap and use half-open date ranges that stay correct across databases.
Read postSQL DELETE vs TRUNCATE vs DROP: Choose Safely
By Sharon Ben-Moshe · Aug 21, 2026
DELETE removes selected rows, TRUNCATE empties a table, and DROP removes the table itself. Learn the crucial differences before running destructive SQL.
Read postTry it now
Paste your SQL into sqlfmt — format, validate, and catch typos free in your browser.