Bird
0
0

Given two tables:

medium📝 query result Q13 of 15
SQL - Set Operations
Given two tables:
Table A: id
1
2
3

Table B: id
2
3
4

What is the result of:
SELECT id FROM A UNION SELECT id FROM B;
A[1, 2, 3, 4]
B[1, 2, 2, 3, 3, 4]
C[2, 3]
D[1, 4]
Step-by-Step Solution
Solution:
  1. Step 1: List rows from both tables

    Table A has ids 1, 2, 3; Table B has ids 2, 3, 4.
  2. Step 2: Apply UNION behavior

    UNION combines all rows and removes duplicates, so final list is 1, 2, 3, 4.
  3. Final Answer:

    [1, 2, 3, 4] -> Option A
  4. Quick Check:

    UNION removes duplicates = [1, 2, 3, 4] [OK]
Quick Trick: UNION removes duplicates, so no repeated ids appear [OK]
Common Mistakes:
MISTAKES
  • Expecting duplicates to appear
  • Confusing UNION with UNION ALL
  • Listing only common ids

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes