Bird
0
0

Given the query:

medium📝 Debug Q6 of 15
SQL - LEFT and RIGHT JOIN
Given the query:
SELECT a.id, b.value FROM A a LEFT JOIN B b ON a.id = b.a_id WHERE b.value IS NULL;
What is the likely purpose of this query?
AFind rows in A with no matching row in B
BFind rows in B with no matching row in A
CFind all rows where b.value is NULL in both tables
DCause an error due to NULL comparison
Step-by-Step Solution
Solution:
  1. Step 1: Understand LEFT JOIN and WHERE condition

    The LEFT JOIN keeps all A rows; WHERE b.value IS NULL filters unmatched B rows.
  2. Step 2: Interpret the result

    This query returns A rows without matching B rows.
  3. Final Answer:

    Find rows in A with no matching row in B -> Option A
  4. Quick Check:

    LEFT JOIN + WHERE b.value IS NULL finds unmatched left rows [OK]
Quick Trick: WHERE right column IS NULL after LEFT JOIN finds unmatched left rows [OK]
Common Mistakes:
MISTAKES
  • Thinking it finds unmatched right rows
  • Assuming NULL comparison causes error
  • Confusing which table is left or right

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes