10.6 CROSS JOIN
Level: 10 | Version: v1.1 | Author: Meptrasoft
Overview
CROSS JOIN returns every possible combination of rows from two tables.
It does not use an ON condition.
Table A × Table B
↓
Every possible combination
If Table A has 2 rows and Table B has 3 rows:
2 × 3 = 6 rows
CROSS JOIN → Every row paired with every row.

Practice Tables
Customers
| id | name |
|---|---|
| 1 | Michael |
| 2 | Sophia |
Orders
| order_id | amount |
|---|---|
| 101 | 999 |
| 102 | 4999 |
Basic CROSS JOIN
SELECT c.name, o.order_id, o.amount
FROM customers_test c
CROSS JOIN orders_test o;
With 2 customers and 2 orders:
2 × 2 = 4 rows
Result:
| name | order_id | amount |
|---|---|---|
| Michael | 101 | 999 |
| Michael | 102 | 4999 |
| Sophia | 101 | 999 |
| Sophia | 102 | 4999 |
Notice that the query does not check whether the customer actually placed the order.
CROSS JOIN vs INNER JOIN
INNER JOIN
→ MATCH RELATED ROWS
CROSS JOIN
→ COMBINE EVERY ROW
CROSS JOIN is useful when you genuinely need all combinations, such as generating possible product/size combinations or test scenarios.
Common Beginner Mistake
A CROSS JOIN can produce a very large result.
For example:
1,000 rows × 10,000 rows
= 10,000,000 rows
So it should be used carefully.
CROSS JOIN can cause a result-set explosion.
Placement Quick Points
CROSS JOINproduces every possible row combination.- It does not require an
ONcondition. - Result size = rows in Table A × rows in Table B.
- It is also called a Cartesian product.
- Large tables can produce extremely large results.
Interview Questions
- What is a CROSS JOIN?
A
CROSS JOINreturns every possible combination of rows from two tables.- Does CROSS JOIN use ON?
No.
- How many rows are produced?
If Table A has
mrows and Table B hasnrows:m × n- What is a Cartesian product?
It is the result containing every possible combination of rows from two sets/tables.
- What is a common risk of CROSS JOIN?
It can produce a very large result set when both tables contain many rows.
Practice & Hands-On Exercises
- Write a
CROSS JOINbetweencustomers_testandorders_test:
SELECT c.name, o.order_id, o.amount
FROM customers_test c
CROSS JOIN orders_test o;
- Count the number of rows produced.
- Explain why 2 × 2 produces 4 rows.
- Explain the difference between
CROSS JOINandINNER JOIN. - What would happen with 100 customers and 1,000 products?
💡 Tip: Test your queries using the in-browser interactive runner above.
Key Takeaway
CROSS JOIN
↓
EVERY ROW × EVERY ROW
↓
m × n COMBINATIONS
CROSS JOIN creates a Cartesian product by pairing every row from the first table with every row from the second table.
End of CROSS JOIN