Bird
0
0

Find the error in this query:

medium📝 Debug Q7 of 15
SQL - Subqueries
Find the error in this query:
SELECT * FROM orders WHERE customer_id IN (SELECT customer FROM customers)
AIN cannot be used with subqueries
BMissing WHERE clause in subquery
CColumn name mismatch between main and subquery
DSELECT * is not allowed with subqueries
Step-by-Step Solution
Solution:
  1. Step 1: Compare columns in main and subquery

    Main query filters on customer_id but subquery selects customer column.
  2. Step 2: Identify mismatch

    Column names must match or be compatible for IN to work correctly.
  3. Final Answer:

    Column name mismatch between main and subquery -> Option C
  4. Quick Check:

    Matching columns needed for IN subqueries [OK]
Quick Trick: Ensure columns match between main query and subquery [OK]
Common Mistakes:
MISTAKES
  • Ignoring column name differences
  • Thinking IN can't be used with subqueries
  • Assuming SELECT * causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes