CROSS JOIN
Every row on the left combined with every row on the right, n × m rows out. Almost never the join you want by accident, but essential when you mean it: building a date-dimension scaffold, generating a product-region coverage matrix, or exploding a JSON array into rows.
Syntax #
sql
SELECT a.id, b.id
FROM a
CROSS JOIN b;Example #
Loading SQL editor...
Warning
An accidental CROSS JOIN is almost always a bug. A query that runs fine in dev and melts in production usually has an INNER JOIN with a forgotten or malformed ON clause — many engines fall back to a cartesian product. Use the CROSS JOIN keyword only when you intend it, and always write explicit ON conditions for real joins so malformed ones fail loudly instead of running slowly.