NEW
Also known as: Cartesian Join
An SQL join that returns the Cartesian product of rows from the joined tables, combining every row from one with every row of the other.
DESCRIPTION
A cross join produces all combinations of rows between two sets, with no join condition. It is useful for generating grids, calendars, or combining small reference sets for parameterization. Without subsequent filtering, outputs grow multiplicatively and can explode in size. Some databases treat missing join predicates as implicit cross joins, which is dangerous. Use cross joins intentionally and limit inputs to small, controlled sets. Performance is bound by the product of input cardinalities.
ALTERNATIVE DEFINITIONS
Microsoft Learn
Returns the Cartesian product of the sets of rows from the joined tables.
Defines result as Cartesian product without conditions.
PostgreSQL Documentation
CROSS JOIN returns all rows from the left table multiplied by all rows from the right table.
Highlights multiplicative nature of cross joins.
RELATED TERMS
Join Keys Cartesian Product Filter WHERE Clause JOIN Clause Set Operations Subquery CROSS APPLY Lateral Join
COMPETING TERMS
RELATIONS
- Broader: Join
- Equivalent to: Cartesian Product
KNOWLEDGE AREAS
Programming Languages Data Warehousing & BI Data Engineering
TARGET AUDIENCE
Data Engineer Data Analyst BI Specialist Software Developer Data Modeler
EXTERNAL SOURCES
- Wikipedia - Join (SQL)#Cross join
- Microsoft - Definition and examples
- PostgreSQL - Join types including CROSS JOIN
- Oracle - SELECT syntax and join forms
TOP QUESTIONS
When is a Cross Join useful?
Use it to generate combinations, such as all dates against categories, or to create test grids for metrics.
Category: Example
What risks come with Cross Joins?
Explosive result sizes can crash queries. Always constrain inputs or filter after the join.
Category: Risks
How does a Cross Join differ from an Inner Join?
Cross joins produce every combination; inner joins match rows using a predicate. Inner joins typically yield smaller, meaningful subsets.
Category: Alternatives
Are Cross Joins ever implicit?
Some engines treat missing join conditions as cross joins, which can silently produce huge outputs.
Category: Misunderstanding
Can I use Cross Join with lateral references?
Yes, some platforms support LATERAL/CROSS APPLY, combining cross join semantics with per-row function evaluation.
Category: Implementation
How to optimize a Cross Join?
Limit input sizes, pre-filter early, and materialize small dimensions; consider generating series instead of joining large tables.
Category: Performance
What are alternatives to Cross Join for grids?
Use generated series or arrays to create dimensions without multiplying large tables.
Category: Alternatives
Does order matter in Cross Joins?
No predicate exists, so order is not defined unless specified by ORDER BY after the join.
Category: Misunderstanding
Where to learn more about Cross Joins?
Review your database’s join semantics and practice with small sample tables to observe output growth.
Category: Learning