Bird
0
0

Consider the tables members(id) and subscriptions(member_id). What will this query return?

medium📝 query result Q5 of 15
SQL - LEFT and RIGHT JOIN
Consider the tables members(id) and subscriptions(member_id). What will this query return?
SELECT m.id FROM members m LEFT JOIN subscriptions s ON m.id = s.member_id WHERE s.member_id IS NULL;

Assuming members has 6 rows and subscriptions has 4 rows linked to 4 different members.
AIDs of subscriptions without matching members
BIDs of members who have at least one subscription
CAll member IDs regardless of subscription status
DIDs of members who do not have any subscription
Step-by-Step Solution
Solution:
  1. Step 1: LEFT JOIN behavior

    The query joins all members with their subscriptions, if any.
  2. Step 2: WHERE s.member_id IS NULL

    This filters to only members without matching subscriptions.
  3. Step 3: Result count

    Since 4 members have subscriptions, 6 - 4 = 2 members will be returned.
  4. Final Answer:

    IDs of members who do not have any subscription -> Option D
  5. Quick Check:

    LEFT JOIN + NULL filter returns unmatched left rows [OK]
Quick Trick: NULL in right table column means no match found [OK]
Common Mistakes:
MISTAKES
  • Assuming the query returns members with subscriptions
  • Confusing NULL check on left table columns
  • Ignoring that LEFT JOIN keeps all left rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes