CROSS appears in two core constructs:1. CROSS JOIN – Produces a Cartesian product of two tables, pairing every row from the left table with every row from the right table. Because no join condition is supplied, the result set size equals left_row_count × right_row_count.2. CROSS APPLY (supported in SQL Server, Azure SQL, PostgreSQL 14+, Oracle, and others) – Invokes a table-valued function or sub-query for every row of the outer table, returning the concatenated results. It behaves like a LATERAL join in Standard SQL.Key behaviors- Deterministic ordering is not guaranteed unless ORDER BY is used.- Performance degrades rapidly with large tables due to combinatorial growth.- CROSS JOIN is part of the SQL-92 standard; CROSS APPLY is vendor-specific.- A CROSS join is logically equivalent to INNER JOIN without an ON clause.Caveats- Always estimate row counts before running against production data.- Use explicit JOIN keywords to avoid accidental Cartesian products that occur when comma-separated joins omit a WHERE clause.
JOIN, INNER JOIN, OUTER JOIN, LATERAL, APPLY, NATURAL JOIN, WHERE
SQL-92 (CROSS JOIN); SQL Server 2005 (CROSS APPLY)
An INNER JOIN requires an ON or USING condition to match rows, while a CROSS JOIN has no condition and generates every possible combination of rows.
No. SQL relations are unordered by definition. Add ORDER BY to impose a specific sequence.
Yes. Append a WHERE clause or wrap the join in a sub-query and filter the result set.
The Cartesian product may be huge. Confirm row counts, add filters, or switch to a conditional join to reduce output rows.