SQL - Set OperationsWhich of the following is the correct syntax to combine two SELECT queries using UNION?ASELECT col1 FROM table1 UNION ALL JOIN SELECT col1 FROM table2;BSELECT col1 FROM table1 JOIN SELECT col1 FROM table2;CSELECT col1 FROM table1 WHERE UNION SELECT col1 FROM table2;DSELECT col1 FROM table1 UNION SELECT col1 FROM table2;Check Answer
Step-by-Step SolutionSolution:Step 1: Review correct UNION syntaxThe correct syntax is to write two SELECT statements separated by the UNION keyword.Step 2: Identify invalid optionsOptions B, C, and D misuse JOIN or WHERE with UNION, which is incorrect syntax.Final Answer:SELECT col1 FROM table1 UNION SELECT col1 FROM table2; -> Option DQuick Check:UNION syntax = SELECT ... UNION SELECT ... [OK]Quick Trick: UNION joins SELECTs directly, no JOIN or WHERE needed [OK]Common Mistakes:MISTAKESUsing JOIN instead of UNIONPlacing WHERE before UNIONCombining UNION ALL with JOIN incorrectly
Master "Set Operations" in SQL9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More SQL Quizzes Aggregate Functions - SUM function - Quiz 15hard GROUP BY and HAVING - GROUP BY with NULL values behavior - Quiz 15hard INNER JOIN - Self join concept - Quiz 10hard LEFT and RIGHT JOIN - Multiple LEFT JOINs in one query - Quiz 5medium Set Operations - INTERSECT for common rows - Quiz 13medium Set Operations - INTERSECT for common rows - Quiz 12easy Subqueries - Subquery vs JOIN performance trade-off - Quiz 8hard Table Relationships - One-to-many relationship design - Quiz 12easy Table Relationships - ER diagram to table mapping - Quiz 8hard Views - Updatable views and limitations - Quiz 8hard