UNION Operator - SQL
Overview
The UNION Operator in SQL is used to combine the result sets of two or more SELECT statements into a single result set. It eliminates duplicate rows by default.
Syntax:
SELECT column1, column2
FROM table1
UNION
SELECT column1, column2
FROM table2
SELECT column1, column2, ... FROM table1
specifies the columns to select from the first table.
UNION
combines the results of the two SELECT statements.
SELECT column1, column2, ... FROM table2
specifies the columns to select from the second table. The number and data types of columns in both SELECT statements must match.