Bird
0
0

Identify the error in this SQL query:

medium📝 Debug Q14 of 15
SQL - Subqueries
Identify the error in this SQL query:
SELECT name FROM Employees WHERE dept_id = SELECT dept_id FROM Departments WHERE dept_name = 'HR';
AUsing = instead of IN for subquery
BMissing parentheses around the subquery
CWrong table name used in subquery
DSubquery returns multiple columns
Step-by-Step Solution
Solution:
  1. Step 1: Check subquery syntax

    The subquery must be enclosed in parentheses to be valid inside WHERE clause.
  2. Step 2: Identify the missing parentheses

    The query lacks parentheses around the subquery, causing syntax error.
  3. Final Answer:

    Missing parentheses around the subquery -> Option B
  4. Quick Check:

    Subqueries need parentheses [OK]
Quick Trick: Always wrap subqueries in parentheses [OK]
Common Mistakes:
MISTAKES
  • Forgetting parentheses around subquery
  • Using wrong operator without parentheses
  • Assuming subquery syntax is optional

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes