Bird
0
0

Identify the error in this query:

medium📝 Debug Q6 of 15
SQL - Set Operations
Identify the error in this query:
SELECT id, name FROM Employees UNION SELECT id FROM Managers;
AUsing UNION without ORDER BY
BMissing WHERE clause in second SELECT
CUNION cannot be used with different tables
DDifferent number of columns in SELECT statements
Step-by-Step Solution
Solution:
  1. Step 1: Check column counts in SELECTs

    First SELECT has 2 columns, second SELECT has 1 column.
  2. Step 2: Understand UNION column requirement

    UNION requires same number of columns in both SELECT queries.
  3. Final Answer:

    Different number of columns in SELECT statements -> Option D
  4. Quick Check:

    Column count mismatch error = A [OK]
Quick Trick: UNION needs same number of columns in both SELECTs [OK]
Common Mistakes:
MISTAKES
  • Ignoring column count mismatch
  • Thinking WHERE clause is mandatory
  • Believing UNION only works on one table

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes