Here’s how to use the UNION and UNION ALL operators.

You may have already had the need to join / combine the result of two or more queries into the database to analyze the results. Well, Oracle makes available to us UNION and UNION ALL operators, it happens that although they are very similar there is a difference between them.

UNION is used to combine the sets of two or more queries into the database, and it removes the duplicate lines between the things done.

UNION ALL does the same thing with the difference that it does not remove duplicate rows. It shows everything.

The syntaxes are almost the same.

SYNTAX OF THE UNION

SELECT expression1, expression2, … expression_n
FROM tables
[WHERE conditions]

UNION

SELECT expression1, expression2, … expression_n
FROM tables
[WHERE conditions];

 

SYNTAX OF UNION ALL

SELECT expression1, expression2, … expression_n
FROM tables
[WHERE conditions]

UNION ALL

SELECT expression1, expression2, … expression_n
FROM tables
[WHERE conditions];

Well, I’ll stop here. Inquiries, please contact us.

Strong hug.

Eduardo Santana
bufallos@bufallos.com.br

Leave a Reply

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