UNION & Combining Results in SQL
From the SQL cheat sheet · Joins · verified Jul 2026
UNION & Combining Results
Combine result sets from multiple queries.
sql
-- UNION — combine and remove duplicates
SELECT name, email FROM customers
UNION
SELECT name, email FROM suppliers;
-- UNION ALL — combine and keep duplicates (faster)
SELECT city FROM users
UNION ALL
SELECT city FROM offices;💡 UNION removes duplicates (slower); UNION ALL keeps all rows (faster) — use ALL when you can
⚡ All SELECT statements in a UNION must have the same number of columns with compatible types
📌 ORDER BY goes at the very end and applies to the combined result
🟢 INTERSECT finds common rows; EXCEPT (or MINUS in Oracle) finds rows unique to the first query
unionintersectexceptcombining