Bird
0
0

What will be the output of this query?

medium📝 query result Q5 of 15
SQL - Set Operations
What will be the output of this query?
SELECT id FROM Table1 INTERSECT SELECT id FROM Table2;
Given:
Table1: {10, 20, 30}
Table2: {20, 30, 40}
A{20, 30}
B{10, 20, 30, 40}
C{10}
D{} (empty set)
Step-by-Step Solution
Solution:
  1. Step 1: Understand INTERSECT operation

    INTERSECT returns only rows present in both tables.
  2. Step 2: Find common rows

    Common ids between Table1 and Table2 are 20 and 30.
  3. Final Answer:

    {20, 30} -> Option A
  4. Quick Check:

    INTERSECT = common rows only [OK]
Quick Trick: INTERSECT returns only shared rows between tables [OK]
Common Mistakes:
MISTAKES
  • Expecting all rows combined
  • Confusing INTERSECT with UNION
  • Assuming empty result when common rows exist

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes