Skip to main content
The UNION clause is used to combine the result of multiple queries. UNION combines the results of two or more queries into a single result set that includes all the rows that belong to all queries in the union. The number and the names of the columns must be identical in all queries combined by using UNION. To keep all the result rows, use UNION ALL. Using just UNION will combine and remove duplicates from the result set.

Frequently Asked Questions

UNION combines results and removes duplicates. UNION ALL keeps all rows including duplicates, which is typically faster since no deduplication is needed.
Yes. The number and names of columns must be identical across all queries combined with UNION. Use AS aliases to ensure column names match.
ORDER BY can be applied to the final combined result set after the UNION. Each individual query in the union cannot have its own ORDER BY unless wrapped in a CALL {} subquery.