Cross Join

A CROSS JOIN returns the Cartesian product of two tables - every row from the first table combined with every row from the second, with no matching condition required.

Basic Syntax

SELECT c.first_name, p.product_name
FROM customers c
CROSS JOIN products p;

If customers has 10 rows and products has 5 rows, this returns 10 x 5 = 50 rows - every possible customer-product pairing.

When to Use a Cross Join

  • Generating all possible combinations, such as pairing every size with every color for a product catalog
  • Building a complete date x category grid before filling in actual data
  • Creating test data with every possible combination of input values
Cross joins can produce enormous result sets very quickly - joining two 10,000-row tables produces 100 million rows, so use them deliberately and on small tables.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course