Bird
0
0

You have two tables with duplicate keys:

hard📝 Application Q9 of 15
SQL - INNER JOIN
You have two tables with duplicate keys:
Table A: (id, val)
Table B: (id, val)
When joining on id, how does the join engine handle multiple matching rows?
AIt picks only the first matching row from Table B
BIt creates a row for every combination of matching rows (Cartesian product for matches)
CIt returns an error due to duplicate keys
DIt ignores duplicates and returns only unique rows
Step-by-Step Solution
Solution:
  1. Step 1: Understand join with duplicates

    When multiple rows match on join keys, the engine pairs each matching row from both tables.
  2. Step 2: Resulting row count

    This creates a Cartesian product of matching rows for those keys.
  3. Final Answer:

    It creates a row for every combination of matching rows (Cartesian product for matches) -> Option B
  4. Quick Check:

    Join duplicates produce all matching pairs [OK]
Quick Trick: Joins multiply rows when keys have duplicates [OK]
Common Mistakes:
MISTAKES
  • Thinking join picks only one match
  • Assuming duplicates cause errors
  • Believing duplicates are automatically removed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes