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 ALL</code> includes duplicate rows, <code>UNION</code> removes duplicates
B<code>UNION ALL</code> removes duplicates, <code>UNION</code> includes duplicates
C<code>UNION ALL</code> sorts the result, <code>UNION</code> does not
D<code>UNION ALL</code> only works with numeric columns, <code>UNION</code> works with all
Step-by-Step Solution
Solution:
  1. Step 1: Understand the behavior of UNION

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

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

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

    UNION ALL behavior = includes duplicates [OK]
Quick Trick: UNION ALL keeps duplicates; UNION removes them [OK]
Common Mistakes:
MISTAKES
  • Confusing UNION ALL with UNION
  • Thinking UNION ALL removes duplicates
  • Assuming UNION ALL sorts results

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes