Bird
0
0

Which of the following is the correct syntax to use a subquery with the IN operator?

easy📝 Syntax Q12 of 15
SQL - Subqueries
Which of the following is the correct syntax to use a subquery with the IN operator?
ASELECT * FROM employees WHERE IN department_id (SELECT id FROM departments);
BSELECT * FROM employees WHERE department_id = IN (SELECT id FROM departments);
CSELECT * FROM employees WHERE department_id IN (SELECT id FROM departments);
DSELECT * FROM employees WHERE department_id IN SELECT id FROM departments;
Step-by-Step Solution
Solution:
  1. Step 1: Review correct IN syntax

    The IN operator must be followed by parentheses enclosing the subquery.
  2. Step 2: Check each option

    SELECT * FROM employees WHERE department_id IN (SELECT id FROM departments); correctly uses IN with parentheses and a subquery. Options A, B, and D have syntax errors.
  3. Final Answer:

    SELECT * FROM employees WHERE department_id IN (SELECT id FROM departments); -> Option C
  4. Quick Check:

    IN syntax = IN (subquery) [OK]
Quick Trick: Use parentheses around subquery after IN [OK]
Common Mistakes:
MISTAKES
  • Adding = before IN
  • Missing parentheses around subquery
  • Placing IN before column name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes