Bird
0
0

In PostgreSQL, what happens when you use the UNION operator to combine the results of two SELECT statements?

easy📝 Conceptual Q1 of 15
PostgreSQL - Set Operations and Advanced Queries
In PostgreSQL, what happens when you use the UNION operator to combine the results of two SELECT statements?
AIt merges the results and removes duplicate rows.
BIt merges the results and keeps all duplicate rows.
CIt only returns rows that appear in both SELECT statements.
DIt returns an error if the SELECT statements have different column names.
Step-by-Step Solution
Solution:
  1. Step 1: Understand UNION behavior

    The UNION operator combines the results of two SELECT queries.
  2. Step 2: Duplicate handling

    Unlike UNION ALL, UNION removes duplicate rows from the combined result set.
  3. Final Answer:

    It merges the results and removes duplicate rows. -> Option A
  4. Quick Check:

    UNION removes duplicates [OK]
Quick Trick: UNION removes duplicates, UNION ALL keeps all rows [OK]
Common Mistakes:
  • Confusing UNION with UNION ALL
  • Thinking UNION returns only common rows
  • Assuming UNION requires identical column names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes