UNION Operator

The UNION operator is used to combine the results of two or more SELECT queries, removing duplicate rows from the result set.

Example: Using UNION

SELECT Name FROM FreedomFighters WHERE City = 'Chennai'
UNION
SELECT Name FROM FreedomFighters WHERE Contribution = 'Healthcare';

Output:

Combines the names of freedom fighters from Chennai and those who contributed to healthcare, with duplicates removed.

Notes

  • Both SELECT queries must have the same number of columns.
  • Data types of corresponding columns must be compatible.