Bird
0
0

Identify the error in this SQL query:

medium📝 Debug Q6 of 15
SQL - Subqueries
Identify the error in this SQL query:
SELECT emp_id FROM Employees WHERE dept_id IN SELECT dept_id FROM Departments WHERE dept_name = 'Finance';
AMissing parentheses around the subquery
BUsing IN instead of EXISTS
CIncorrect column name in WHERE clause
DUsing SELECT without FROM clause
Step-by-Step Solution
Solution:
  1. Step 1: Check subquery syntax

    The subquery must be enclosed in parentheses when used with IN.
  2. Step 2: Identify error

    The query lacks parentheses around the subquery after IN.
  3. Final Answer:

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

    IN requires subquery in parentheses [OK]
Quick Trick: Always enclose subquery in parentheses with IN [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around subquery
  • Confusing IN with EXISTS syntax
  • Misplacing WHERE clause

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes