SQL · Pattern 7 — Set Operators
UNION ALL
UNION ALL combines multiple result sets but keeps duplicate rows.
Source data — Pattern 7: Set Operators
All queries run against the shared employees table (see schema.sql). This pattern introduces the former_employees table. Topic 44 also introduces a retired_employees table to demonstrate combining multiple set operators in a single query.



What it does
UNION ALL combines multiple result sets but keeps duplicate rows. Since duplicate removal is not performed, it is generally faster than UNION.
Problem
Display the names of all current and former employees, including duplicate records.
SELECT first_name, last_name
FROM employees
UNION ALL
SELECT first_name, last_name
FROM former_employees;
Result
