Produces the cartesian product of two tables — every row of the left combined with every row of the right. No join condition.

Produces a Cartesian product: every row in the first table paired with every row in the second. Can be extremely large and expensive. Occasionally useful for generating combinations (e.g., all date/user pairs) when paired with a WHERE clause that filters most results away.

Compatibility

Show:
Database System Support Status Since Version Notes
MySQL ✓ Supported all CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.
PostgreSQL ✓ Supported all CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.
SQL Server ✓ Supported all CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.
Oracle ✓ Supported all CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.
SQLite ✓ Supported all CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.

Details

Rarely needed in application code but useful for generating combinations or test data. N rows × M rows = N*M result rows.

Standard Syntax

SELECT a.col, b.col FROM table_a a CROSS JOIN table_b b;

Version Support

MySQL: Since all PostgreSQL: Since all SQL Server: Since all Oracle: Since all SQLite: Since all

Per-Database Syntax & Notes

MySQL

CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.

SELECT a.col, b.col FROM a CROSS JOIN b;

PostgreSQL

CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.

SELECT a.col, b.col FROM a CROSS JOIN b;

SQL Server

CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.

SELECT a.col, b.col FROM a CROSS JOIN b;

Oracle

CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.

SELECT a.col, b.col FROM a CROSS JOIN b;

SQLite

CROSS JOIN keyword or comma syntax (FROM a, b) both produce a cartesian product.

SELECT a.col, b.col FROM a CROSS JOIN b;