Bird
0
0

Given two tables:

medium📝 query result Q4 of 15
SQL - Set Operations
Given two tables:
Customers: id, name
1, John
2, Jane

Subscribers: id, name
2, Jane
3, Mike

What will be the result of:
SELECT name FROM Customers UNION SELECT name FROM Subscribers;
AJohn, Jane, Mike
BJohn, Jane, Jane, Mike
CJohn, Mike
DJane, Mike
Step-by-Step Solution
Solution:
  1. Step 1: Understand UNION behavior

    UNION returns distinct rows from both queries combined.
  2. Step 2: Analyze data

    Customers names: John, Jane; Subscribers names: Jane, Mike
  3. Step 3: Combine distinct names

    Result: John, Jane, Mike
  4. Final Answer:

    John, Jane, Mike -> Option A
  5. Quick Check:

    Duplicates removed by UNION [OK]
Quick Trick: UNION removes duplicates from combined results [OK]
Common Mistakes:
MISTAKES
  • Assuming UNION ALL behavior
  • Counting duplicates twice
  • Ignoring distinctness of UNION

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes