SQL UNION

The UNION operator in SQL allows you to combine the result sets of two or more SELECT statements into a single result set. The UNION operator removes duplicates from the final result set.

Syntax:

Example:

In this example, the result set will include all the rows from the cars table where the manufacturer is either Toyota or Honda, and the duplicates will be removed.

Note: The number of columns, data types, and column names must be the same in all the SELECT statements being combined using the UNION operator.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top