Back to course home
0% completed
UNION
UNION
The UNION operation combines the result sets of two or more SELECT statements. It returns a result set that contains all the unique rows from the combined sets.
The syntax to use UNION on the table is:
SELECT column_name(s) FROM table1 UNION SELECT column_name(s) FROM table2;
Example
Suppose we have two database tables with the names Customers
and Suppliers
as shown below
Now, we want to fetch the cities from the Customers
and Suppliers
tables. The query will go like this.
And it will show the following result
You may have noticed that even if duplicate c
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible