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;
- 4 rows
- 2 rows
- 3 rows
- 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
- Table MondaySale: item Tea Samosa Tea Vada Table TuesdaySale: item Samosa Poha…
- Table Employee: id | name 1 | Kavya 2 | Lokesh Table Intern: id | name |…
- Table SectionA: name | marks Gita | 70 Hari | 90 Table SectionB: name | marks…
- Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina…
- Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina…
- Table SectionA: name | marks Gita | 70 Hari | 90 Table SectionB: name | marks…
- Table Customer(cust_id, name) has 5 rows and table Supplier(supp_id, name) has…
- Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina…
- Table MayOrders: order_id | coupon 1 | SAVE10 2 | NULL 3 | NULL Table…
- Table Cricket: student Aman Bina Chetan Bina Table Football: student Bina…
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