Part 66: CROSS JOIN: Cartesian Products & Matrix Generation

Part 66 Technology Updated September 12, 2026

Part 66: CROSS JOIN: Cartesian Products & Matrix Generation

A CROSS JOIN produces the mathematical Cartesian product: every row of Table A is paired with every row of Table B (N × M rows).


1. Generating Product SKU Matrix

-- Combine all colors with all sizes:
SELECT c.color_name, s.size_name
FROM colors c
CROSS JOIN sizes s;

If there are 5 colors and 4 sizes, it generates exactly 20 SKU combinations.


Key Takeaways

  • CROSS JOIN creates all permutations.
  • Ensure input tables are small to prevent generating billions of rows!

In Part 67, we will master SELF JOIN: Hierarchical and Tree Data!