UNION ALL concatenates the results of the two query blocks into a single (larger) result set. Each query block may be nested.
UNION DISTINCT eliminates duplicate rows in the final result. Eliminating duplicates requires extra processing, so UNION ALL
should be used instead of UNION where possible. UNION DISTINCT is identical to UNION.
The result sets of the two query-blocks must be UNION-compatible; they must each have the same number of items in their respective SELECT lists, and the types of
each expression should be comparable. If corresponding items in two SELECT lists have different data types, SQL Anywhere chooses
a data type for the corresponding column in the result and automatically convert the columns in each query-block appropriately.
The column names displayed are the same column names that are displayed for the first query-block and these names are used to determine the expression names to be matched with the ORDER BY clause. An alternative way of
customizing result set column names is to use a common table expression (the WITH clause).
UNION is a core feature of the SQL/2008 standard. Explicitly specifying the DISTINCT keyword with UNION is optional SQL
language feature T551. Specifying an ORDER BY clause with UNION is SQL language feature F850. A query-block that contains an ORDER BY clause constitutes SQL/2008 feature F851. A query block that contains a row-limit clause (SELECT
TOP or LIMIT) comprises optional SQL language feature F857 or F858, depending on the context. The FOR XML and OPTION clauses
are vendor extensions.
UNION and UNION ALL are supported by Adaptive Server Enterprise. The FOR XML and OPTION clauses are not supported.