Bird
0
0

Which of the following is the correct syntax to combine two SELECT queries using UNION in PostgreSQL?

easy📝 Syntax Q12 of 15
PostgreSQL - Set Operations and Advanced Queries
Which of the following is the correct syntax to combine two SELECT queries using UNION in PostgreSQL?
ASELECT col1 FROM table1 JOIN SELECT col1 FROM table2;
BSELECT col1 FROM table1 UNION SELECT col1 FROM table2;
CSELECT col1 FROM table1 + SELECT col1 FROM table2;
DSELECT col1 FROM table1 INTERSECT SELECT col1 FROM table2;
Step-by-Step Solution
Solution:
  1. Step 1: Recall UNION syntax

    The correct syntax uses UNION keyword between two SELECT statements with matching columns.
  2. Step 2: Check options

    Only SELECT col1 FROM table1 UNION SELECT col1 FROM table2; is correct. JOIN is for table joins; + is invalid syntax; INTERSECT is a different operation.
  3. Final Answer:

    SELECT col1 FROM table1 UNION SELECT col1 FROM table2; -> Option B
  4. Quick Check:

    UNION syntax = SELECT ... UNION SELECT ... [OK]
Quick Trick: UNION joins SELECTs with UNION keyword, no + or JOIN [OK]
Common Mistakes:
  • Using + instead of UNION
  • Confusing JOIN with UNION
  • Mixing INTERSECT with UNION syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes