Union of the results of the underlying queries, with duplicates removed.
Behavior is identical to using UNION ALL
followed by SELECT DISTINCT *
.
Refer to UNION ALL for more details.
SELECT key FROM T1
UNION
SELECT key FROM T2 -- returns the set of distinct keys in the tables
Concatenating results of multiple SELECT
statements (or subqueries).
Two UNION ALL
modes are supported: by column names (the default mode) and by column positions (corresponds to the ANSI SQL standard and is enabled by the PRAGMA).
In the "by name" mode, the output of the resulting data schema uses the following rules:
NULL
).The order of output columns in this mode is equal to the largest common prefix of the order of inputs, followed by all other columns in the alphabetic order. If the largest common prefix is empty (for example, if the order isn't specified for one of the inputs), then the output order is undefined.
In the "by position" mode, the output of the resulting data schema uses the following rules:
The order of the output columns in this mode is the same as the order of columns in the first input.
SELECT 1 AS x
UNION ALL
SELECT 2 AS y
UNION ALL
SELECT 3 AS z;
In the default mode, this query returns a selection with three columns x, y, and z. When PRAGMA PositionalUnionAll;
is enabled, the selection only includes the x column.
PRAGMA PositionalUnionAll;
SELECT 1 AS x, 2 as y
UNION ALL
SELECT * FROM AS_TABLE([<|x:3, y:4|>]); -- error: the order of columns in AS_TABLE is undefined