SQL · Pattern 6 — Joins
CROSS JOIN
CROSS JOIN returns every possible combination of rows from both tables without a join condition.
Source data — Pattern 6: Joins
All queries run against the shared employees and departments tables (see schema.sql). This pattern introduces the departments table. Topic 38 also needs a projects table, while topic 39 introduces a salary_grades table for non-equi joins.




What it does
CROSS JOIN returns every possible combination of rows from both tables without a join condition.
Problem
Generate all employee-department combinations.
SELECT e.first_name,
d.department_name
FROM employees e
CROSS JOIN departments d;

Note
Only the first 12 rows are shown. The complete CROSS JOIN result contains 36 rows (6 employees × 6 departments).