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
Building an Enterprise SQL Style Guide: Formatting Standards, Linting, and Team Conventions
By Sharon Ben-Moshe · Oct 13, 2026
The complete blueprint for an enterprise SQL style guide. Standardize formatting, keyword casing, indentation, naming conventions, and CI linting.
Read postThe Master Guide to SQL Common Table Expressions (CTEs): Syntax, Optimization Fences, and Recursion
By Sharon Ben-Moshe · Oct 13, 2026
The definitive guide to SQL Common Table Expressions (CTEs). Master chaining, recursive hierarchies, data-modifying CTEs, and optimization fences.
Read postTry it now
Paste your SQL into sqlfmt — format, validate, and catch typos free in your browser.