SQL CROSS JOIN cardinality 1 question in 2 chapters

  1. 01Cartesian products
  2. 02Sources

Cartesian products

  • 1.1 How many rows does a comma join return, and what happens when one table is empty? Easy 2 min

    With ten rows in the first table and twenty in the second, the query returns two hundred rows, because every row pairs with every row on the other side. If the first table becomes empty, the result has zero rows, not twenty. This is a cross join, not an outer join. I write cross join explicitly when I really want all combinations, so a missing join condition is easier to spot.

    Read the full answer

Sources