UNION, INTERSECT & EXCEPT · Question 11 · Medium

Table Store: city | product Pune | Pen Pune | Ink Table Depot: city | product Pune | Pen Goa | Pen How many rows does this query return?

SELECT city, product FROM Store
UNION
SELECT city, product FROM Depot;
  1. 4 rows
  2. 2 rows
  3. 3 rows
  4. 1 row
Answer and explanation

Answer: C. 3 rows

Explanation: UNION compares whole rows. (Pune, Pen) appears in both tables and is kept once; (Pune, Ink) and (Goa, Pen) are each different from it in one column, so they stay. The result is 3 rows.

Previous: Table SectionA: name | marks Gita | 70 Hari | 90 Table SectionB: name | marks… · Next: Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina…

Practise union, intersect & except

Try a fresh set of union, intersect & except questions with an explanation after every answer, free and without signing up: UNION, INTERSECT & EXCEPT practice. Or sit a full placement mock test.

More union, intersect & except questions

More sql practice

Tables, Keys & Constraints · DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge