$ ./guess_the_languageSQL & Databases
SQL & Databases · medium · #10

How many rows does the join produce?

-- a has 2 rows with id = 1
-- b has 3 rows with id = 1
SELECT * FROM a
JOIN b ON a.id = b.id;
  1. 3
  2. 2
  3. 5
  4. 6
Each matching left row pairs with each matching right row, so duplicate keys multiply: 2 x 3 = 6.
Play SQL & Databases ▸