UNION
UNION is a SQL statement in the Set Operations category. Combines results from two queries, removing duplicate rows. Each SELECT must have the same number of columns. The syntax is SELECT columns FROM table1 UNION SELECT columns FROM table2;. It returns combined distinct rows. A typical example: SELECT name, email FROM customers UNION SELECT name, email FROM employees; -- All contacts from both tables (duplicates removed) A close relative is UNION ALL, which like UNION but does NOT remove duplicate rows. Faster because no dedup is needed. A close relative is INTERSECT, which returns rows that appear in BOTH query results. Supported in PostgreSQL, SQL Server, Oracle. A close relative is EXCEPT / MINUS, which returns rows from the first query that do NOT appear in the second query results. More about this category: Set-based operations — UNION, UNION ALL, INTERSECT, EXCEPT. Related Set Operations entries: UNION ALL, INTERSECT, EXCEPT / MINUS, INTERSECT ALL / EXCEPT ALL, Ordering Set Operations, TABLE Keyword, Set Operation Precedence, Set Operation with ORDER BY.