r/tech.unpacked01 · u/tech.unpacked01 ·

How a SQL cross join works: 4 × 3 makes 12 rows

How a SQL cross join works: 4 × 3 makes 12 rows

4 colours and 3 sizes give 12 rows.

A cross join pairs every row of one table with every row of the other. Nothing is matched, so the count multiplies: two tables of 40 rows give 1,600, and two of 10,000 give 100 million.

Save it for the day a query returns far too many rows.

#sql #crossjoin #database #coding #learnsql #technology