|
|
|
| UNION |
|
Combine the unique rows returned by 2 SELECT statements.
The UNION operator returns only distinct rows that appear in either result
  SELECT product_id FROM order_items
  UNION
  SELECT product_id FROM inventories;
|
| UNION ALL |
|
Combine the rows returned by 2 SELECT statements
(including all duplicates).
The UNION ALL operator does not eliminate duplicate selected rows:
  SELECT location_id FROM locations
  UNION ALL
  SELECT location_id FROM departments;
A location_id value that appears multiple times in either or both queries (such as '1700')
is returned only once by the UNION operator, but multiple times by the UNION ALL operator.
|
| INTERSECT |
|
Return only those rows that are in *both* SELECT statements.
The following combines the results with the INTERSECT operator, which returns only those rows returned by
both queries:
  SELECT product_id FROM inventories
  INTERSECT
  SELECT product_id FROM order_items;
|
| MINUS |
|
Return the rows that are in the first SELECT but not the second.
The following combines results with the MINUS operator, which returns only rows returned by the first query but not by
the second:
  SELECT product_id FROM inventories
  MINUS
  SELECT product_id FROM order_items;
|