UNION-clause::=UNION[ALL
]relation-expression
Links together multiple SELECT clauses and executes them as a single CQL statement.
ALL
If ALL is specified, duplicate rows are allowed.
If UNION is specified without the ALL operand, duplicate rows are excluded.
Excluding duplicate rows means that, if duplicate rows (identical rows consisting of the items specified in the select expression) exist in the search result, they are deleted and only a single row is output.
relation-expression
For details about specifying a relation expression, see 4.4.3 Relation expression.
A query specifying the following two conditions at the same time causes a syntax error:
The following example causes a syntax error. The underlined part indicates the location that causes the error.
REGISTER QUERY q1 ISTREAM(
SELECT * FROM s1[RANGE 3 SECOND]
UNION ALL SELECT * FROM s1[RANGE 5 SECOND]);
SELECT * FROM s1[RANGE 3 SECOND] UNION ALL SELECT * FROM s1[RANGE 5 SECOND];
Outputs all data in relations s1 and s2. The underlined part indicates the UNION clause.
REGISTER QUERY s1 SELECT * FROM s1[ROWS 100] UNION SELECT * FROM s2[ROWS 100];