Browse SQL Topics ▼

CROSS JOIN (Cartesian Products)

📂 Combining Tables (JOINs) 📘 Lesson 47 of 81

Generate every possible pairwise combination between two sets of data with CROSS JOIN.

CROSS JOIN (Cartesian Products) is an essential topic in SQL and relational database engineering.

Overview

Building on foundational principles introduced in right-full-joins, mastering cross join (cartesian products) provides the core mental model and practical query skills needed for production relational database engineering.

-- Generate all shirt sizes across all colors:
SELECT s.size, c.color
FROM sizes s
CROSS JOIN colors c;

Key Concepts

  • Understand the fundamental syntax, conventions, and mental model.
  • Avoid common beginner traps, data type mismatches, and performance pitfalls.
  • Apply practical idioms directly in production applications.

[!TIP] Master this concept to build a rock-solid foundation. Next, proceed to self-joins.

Test your understanding of CROSS JOIN (Cartesian Products)

Quick interactive practice questions with instant feedback.

Take Quiz →