Skip to main content
UNION and UNION ALL let you merge the results of two or more independent queries into a single result set. Both queries can target different files, different paths within the same file, or different filter conditions.

UNION vs UNION ALL

Column count requirement

The number of selected columns must match across all combined queries. If they do not match, FiQueLa throws a QueryLogicException.
Queries using SELECT * skip this validation.

Basic usage

Chaining multiple unions

You can chain as many unions as needed. Each union executes its own independent pipeline.

How UNION interacts with EXPLAIN

When you run EXPLAIN or EXPLAIN ANALYZE on a query that includes a union, each union branch reports its own sub-phases in the output. Single union produces phases like:
Multiple unions index each branch:
See EXPLAIN and EXPLAIN ANALYZE for the full column reference.
Each union sub-query executes its own full pipeline — FROMWHEREGROUP BYSELECT → etc. Clauses like ORDER BY and LIMIT on the main query apply to the final merged result, not to individual branches.