Bird
0
0

Identify the error in this query:

medium📝 Debug Q14 of 15
SQL - Subqueries
Identify the error in this query:
SELECT emp_id FROM Employees WHERE dept_id IN SELECT dept_id FROM Departments;
ASubquery should be in the FROM clause.
BUsing IN instead of EXISTS.
Cdept_id should be compared with = not IN.
DMissing parentheses around the subquery after IN.
Step-by-Step Solution
Solution:
  1. Step 1: Check IN operator syntax

    The IN operator requires the subquery to be enclosed in parentheses.
  2. Step 2: Identify missing parentheses

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

    Missing parentheses around the subquery after IN. -> Option D
  4. Quick Check:

    IN needs (subquery) [OK]
Quick Trick: Always put subquery inside parentheses after IN [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses around subquery
  • Confusing IN with EXISTS
  • Using = instead of IN for multiple values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes