Bird
0
0

Which of the following is the correct syntax for a nested subquery in SQL?

easy📝 Syntax Q12 of 15
SQL - Subqueries
Which of the following is the correct syntax for a nested subquery in SQL?
ASELECT * FROM table WHERE id IN SELECT id FROM table2 WHERE value = 10;
BSELECT * FROM table WHERE id == (SELECT id FROM table2 WHERE value = 10);
CSELECT * FROM table WHERE id = SELECT id FROM table2 WHERE value = 10;
DSELECT * FROM table WHERE id = (SELECT id FROM table2 WHERE value = 10);
Step-by-Step Solution
Solution:
  1. Step 1: Review correct nested subquery syntax

    The inner query must be enclosed in parentheses and used with operators like = or IN.
  2. Step 2: Check each option

    SELECT * FROM table WHERE id = (SELECT id FROM table2 WHERE value = 10); uses parentheses correctly and equals operator, making it valid SQL syntax.
  3. Final Answer:

    SELECT * FROM table WHERE id = (SELECT id FROM table2 WHERE value = 10); -> Option D
  4. Quick Check:

    Nested subquery syntax uses parentheses [OK]
Quick Trick: Always use parentheses around subqueries [OK]
Common Mistakes:
MISTAKES
  • Missing parentheses around subquery
  • Using double equals (==) instead of single =
  • Omitting parentheses causing syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes