Bird
0
0

Given these tables:

medium📝 query result Q4 of 15
SQL - Set Operations
Given these tables:

Table A:
id INT, name VARCHAR
1, 'Alice'
2, 'Bob'

Table B:
id INT, name VARCHAR
2, 'Bob'
3, 'Charlie'

What is the result of:
SELECT id, name FROM A INTERSECT SELECT id, name FROM B;?
A1, 'Alice'<br>2, 'Bob'<br>3, 'Charlie'
B2, 'Bob'
C1, 'Alice'<br>3, 'Charlie'
DNo rows returned
Step-by-Step Solution
Solution:
  1. Step 1: Understand INTERSECT returns common rows

    Rows present in both tables A and B are returned.
  2. Step 2: Identify common rows

    Only (2, 'Bob') exists in both tables.
  3. Final Answer:

    2, 'Bob' -> Option B
  4. Quick Check:

    INTERSECT common rows = A [OK]
Quick Trick: INTERSECT returns only rows in both sets [OK]
Common Mistakes:
MISTAKES
  • Including all rows from both tables
  • Confusing INTERSECT with UNION
  • Ignoring exact row matching

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes