Bird
0
0

What is the main difference between UNION and UNION ALL in SQL?

easy📝 Conceptual Q1 of 15
SQL - Set Operations
What is the main difference between UNION and UNION ALL in SQL?
A<code>UNION</code> requires same column names, <code>UNION ALL</code> does not
B<code>UNION</code> includes duplicates, <code>UNION ALL</code> removes duplicates
C<code>UNION</code> works only with numeric columns, <code>UNION ALL</code> works with all types
D<code>UNION</code> removes duplicate rows, <code>UNION ALL</code> includes duplicates
Step-by-Step Solution
Solution:
  1. Step 1: Understand UNION behavior

    UNION combines results and removes duplicate rows.
  2. Step 2: Understand UNION ALL behavior

    UNION ALL combines results and keeps all rows, including duplicates.
  3. Final Answer:

    UNION removes duplicate rows, UNION ALL includes duplicates -> Option D
  4. Quick Check:

    Difference between UNION and UNION ALL = A [OK]
Quick Trick: UNION removes duplicates; UNION ALL keeps all rows [OK]
Common Mistakes:
MISTAKES
  • Thinking UNION ALL removes duplicates
  • Confusing column name requirements
  • Assuming UNION only works with numbers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes