MySQL SQLLesson 32Free preview
MySQL CROSS JOIN
This lesson is part of MySQL · All levels
Summary
CROSS JOIN returns the result of the cross multiplication: each row of the left table is paired with all the rows of the right table. If the left table has 3 rows and the right table has 4 rows, it's 12 rows. Cross JOIN does not require an ON condition, and in practice is often used to create data combinations such as product color sizes lists or scenario simulations.
Key points
- CROSS JOIN results in the Cartesian product of two tables
- The number of rows resulting = the number of rows of the left table × the number of rows of the right table
- No need for an ON clause because all combinations are constants
- When using WHERE, the result is effectively equal to INNER JOIN.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.