Step 9
4 min read

Cross Join

Combine every row with every row - all combinations!

What is Cross Join?

Cross Join combines EVERY row from first table with EVERY row from second table.

Simple rule: 3 colors ร— 2 sizes = 6 combinations

How Cross Join Works

Basic Syntax

SELECT * FROM table1 CROSS JOIN table2;

Example: All Color-Size Combinations

SELECT colors.name, sizes.name FROM colors CROSS JOIN sizes;

Result: 4 rows (2 colors ร— 2 sizes)

Warning!

Cross Join creates many rows fast!

  • 10 ร— 10 = 100 rows
  • 100 ร— 100 = 10,000 rows
  • 1000 ร— 1000 = 1,000,000 rows!

When to Use

  • Generate all product variants (color + size)
  • Create date ranges
  • Test data combinations

Try It Below

Practice with color-size combinations!

Congratulations!

You completed all JOIN types! ๐ŸŽ‰

Finished this topic?

Mark it complete to track your progress and maintain your streak!