Bird
0
0

Given these tables:

medium📝 query result Q13 of 15
PostgreSQL - Set Operations and Advanced Queries
Given these tables:
table_a:
id
1
2
3

table_b:
id
2
3
4

What is the result of:
SELECT id FROM table_a INTERSECT SELECT id FROM table_b;
A[1, 2, 3]
B[1]
C[2, 3]
D[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: Find common ids using INTERSECT

    Common ids are 2 and 3 only.
  3. Final Answer:

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

    INTERSECT = common rows = [2, 3] [OK]
Quick Trick: INTERSECT returns only ids present in both tables [OK]
Common Mistakes:
  • Including ids only in one table
  • Confusing INTERSECT with UNION
  • Expecting all ids combined

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes