SQL UNION ALL appends the output of multiple SELECT statements into one combined result set without removing duplicate rows. Each SELECT must return the same number of columns in the same order and with compatible data types. Because UNION ALL skips the overhead of duplicate elimination performed by UNION (which implies DISTINCT), it is generally faster and preserves every occurrence of each row. ORDER BY can be applied only once, after the final SELECT. LIMIT, OFFSET, or FETCH clauses must also appear at the end, not inside individual SELECT blocks. NULLability follows normal type-promotion rules; column names in the final set default to those in the first SELECT unless aliased. Beware of unintended data explosions when duplicates are expected.
UNION, INTERSECT, EXCEPT, JOIN, WITH (CTE), ORDER BY
SQL-92 standard
It skips duplicate elimination, making queries faster and preserving every row from each SELECT.
Place an ORDER BY clause after the last SELECT in the UNION ALL chain. Sorting inside individual SELECTs is ignored.
Yes, but they must return the same number of columns in the same order and with compatible types. Final column names default to those in the first SELECT unless aliases are supplied there.
Choose UNION when you need duplicate rows removed from the combined result. Otherwise, prefer UNION ALL for speed.