Query Operators

Query operators allow queries to be combined using set operators.

In this Topic:

General Syntax

[(] query [)] operator [(] query [)]
[ORDER BY ...]
[LIMIT ...]

Usage Notes

  • Each query may itself contain query operators, to allow any number of query expressions to be combined with set operators.
  • The ORDER BY and LIMIT clauses are applied to the result of the set operator.

INTERSECT

Returns rows from one query’s result set which also appear in another query’s result set, with duplicate elimination.

Syntax

SELECT ... FROM ...
INTERSECT
SELECT ... FROM

MINUS / EXCEPT

Removes rows from one query’s result set which appear in another query’s result set, with duplicate elimination. The MINUS and EXCEPT keywords have the same meaning.

Syntax

SELECT ... FROM ...
MINUS
SELECT ... FROM

SELECT ... FROM ...
EXCEPT
SELECT ... FROM

UNION

Combines the result sets from two queries:

  • UNION combines with duplicate elimination.
  • UNION ALL combines without duplicate elimination.

Syntax

SELECT ... FROM ...
UNION
SELECT ... FROM

SELECT ... FROM ...
UNION ALL
SELECT ... FROM