Oracle: UNION operator

UNION Operation in oracle helps to find out all the elements of those sets between which the operation applies.

Note The output if the UNION Operation does not repeat the duplicate values.

Syntax

statement
UNION
Statement;

For example:

we have the table Children as:

Children

And, we have the table Stu as:

Stu table

Now, we want to select all the Names, Section, and Roll_No from both Stu and Children tables.

select Name, section, Roll_no from Children
UNION
select Name, section, Roll_no from stu;

OUTPUT:

UNION

NOTE: From the above data we can find out that we have the same entry with the name Radha in both the table. The above output has returned only a single entry for the following data. However, we can say UNION does not return duplicate data multiple times.