Bird
0
0

Given two tables:

medium📝 query result Q13 of 15
SQL - Set Operations
Given two tables:
Employees1:
id | name
1 | Alice
2 | Bob
3 | Carol

Employees2:
id | name
2 | Bob
3 | Carol
4 | Dave

What is the result of this query?
SELECT id, name FROM Employees1 INTERSECT SELECT id, name FROM Employees2;
ARows with Bob and Carol only
BRows with Alice, Bob, Carol, and Dave
CRows with Alice only
DRows with Dave only
Step-by-Step Solution
Solution:
  1. Step 1: List rows from both tables

    Employees1 has (1, Alice), (2, Bob), (3, Carol). Employees2 has (2, Bob), (3, Carol), (4, Dave).
  2. Step 2: Find common rows

    Common rows are those present in both: (2, Bob) and (3, Carol).
  3. Final Answer:

    Rows with Bob and Carol only -> Option A
  4. Quick Check:

    INTERSECT returns common rows = Bob, Carol [OK]
Quick Trick: INTERSECT returns only rows present in both tables [OK]
Common Mistakes:
MISTAKES
  • Including rows unique to one table
  • Confusing UNION with INTERSECT
  • Ignoring column matching in rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes