CROSS JOIN returns the Cartesian product of two tables, meaning every row from the first table is combined with every row from the second table.
CROSS JOIN can be useful for generating combinations, but it can produce a very large result set.
Generate every possible combination of products and sales regions.
SELECT
p.ProductName,
r.RegionName
FROM Products p
CROSS JOIN Regions r;
Used for scenario generation, test data, product-region combinations, scheduling, and planning analysis.
- CROSS JOIN creates all possible combinations.
- It does not require an ON condition.
- Result size can grow rapidly.
- It is useful for generating combinations.
- Use it carefully with large tables.
What does CROSS JOIN return?
It returns every possible combination of rows from the two tables.
Does CROSS JOIN require an ON condition?
No. CROSS JOIN does not require a join condition.