Set Operators
Union/unionall ------------- Union
The Union operator returns all records after two sets are removed from duplicated elements.
Union all returns all records of two sets, including duplicate
Select * from EMP where deptno = 20 and job = 'click'
Union
Select * from EMP where deptno = 10 and job = 'manager'
Intersect ------------- Intersection
The Intersect operator returns records that belong to both sets.
Minus ---------------- difference set
Minus returns a record that belongs to the first set but does not belong to the second set.
NOTE: If AB is regarded as a whole, the difference set between A and B can be considered as a complementary set of B in the AB range. [premise: A and B are two circles with overlapping parts]
Considerations for set operations:
L in the SELECT statement, the parameter types and numbers must be consistent.
L use parentheses to change the sequence of execution of the set.
L The set operation uses the header of the first statement as the header.
L The order by clause can only appear in the last one. The column, name, or alias accepted by the first select statement must be the same as the column name of the first select statement.