
Concept explainers
Consider the below two tables for all the “UNION”, “INTERSECT”, and “MINUS” operations.
Consider two tables:
Table creation:
CREATE TABLE EMPLOYEE(NAME VARCHAR(15));
CREATE TABLE EMPLOYEE_1(NAME VARCHAR(15));
Inserting values:
INSERT INTO EMPLOYEE VALUES("Alice Cordoza");
INSERT INTO EMPLOYEE VALUES("John Cretchakoy");
INSERT INTO EMPLOYEE VALUES("Anne McDonald");
INSERT INTO EMPLOYEE_1 VALUES("John Cretchakoy");
INSERT INTO EMPLOYEE_1 VALUES("Mary Chen");
Explanation of Solution
INTERSECTset operator:
The INTERSECT set operator is used to combine the output of two or more than two queries and produce a result. The produced result contains the values (rows) that are common in both the tables.
Syntax: QUERYINTERSECTQUERY;
INTERSECT query:
SELECT * FROM EMPLOYEE INTERSECT SELECT * FROM EMPLOYEE_1;
Explanation of Solution
MINUS set operator:
The MINUS set operator is used to combine the output of two or more than two queries and produce a result. The produced result contains the values (rows) that appear in the first table but not in the second table. The word “EXCEPT” can also be used in the place of “MINUS”.
Syntax: QUERYMINUSQUERY;
MINUS query 1:
SELECT * FROM EMPLOYEE MINUS SELECT ...
Explanation of Solution
Restrictions on the table:
In order to perform any of the operations like “UNION”, “INTERSECT”, and “MINUS” operations, the tables must be union-compatible...

Want to see the full answer?
Check out a sample textbook solution
Chapter 5 Solutions
A Guide to SQL