Watch the 7.3 Webinar On-Demand
This new release brings updates to Universal Storage, query optimization, and usability that you won’t want to miss.

UNION

Combines results from multiple SELECT statements. UNION DISTINCT removes duplicate rows, while UNION ALL does not remove them. UNION is equivalent to UNION DISTINCT.

Syntax

SELECT ...
UNION [ALL | DISTINCT] SELECT ...
[UNION [ALL | DISTINCT] SELECT ...]

Remarks

  • The first and all subsequent SELECT statements must select the same number of columns.

Examples

SELECT * FROM table_a UNION ALL SELECT * FROM table_b;
SELECT * FROM table_a UNION SELECT * FROM table_b;