Bird
0
0

Given tables orders and customers, what will the following query return?

medium📝 query result Q13 of 15
SQL - Advanced Joins
Given tables orders and customers, what will the following query return?
SELECT customers.name, orders.id FROM customers LEFT JOIN orders ON customers.id = orders.customer_id WHERE orders.id IS NULL;
AAll customers who have not placed any orders
BAll customers who have placed at least one order
CAll orders without a matching customer
DAll customers and their orders
Step-by-Step Solution
Solution:
  1. Step 1: Analyze LEFT JOIN with WHERE condition

    The LEFT JOIN returns all customers with matching orders or NULL if no order exists. The WHERE clause filters rows where orders.id is NULL, meaning no matching order.
  2. Step 2: Interpret the result

    This query returns customers who have no orders because orders.id is NULL for them.
  3. Final Answer:

    All customers who have not placed any orders -> Option A
  4. Quick Check:

    LEFT JOIN + WHERE orders.id IS NULL = customers without orders [OK]
Quick Trick: LEFT JOIN + WHERE right table column IS NULL finds missing matches [OK]
Common Mistakes:
MISTAKES
  • Thinking it returns customers with orders
  • Confusing NULL in orders.id with existing orders
  • Assuming it returns unmatched orders

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes