Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests -

Difference between Union and Union All

Union and Union All are the important SQL operators used for merging the result set from multiple tables. In this article, you will learn the major differences between Union and Union All.

What is Union?

In SQL server, Union is an important operator used for combining two queries into a single result set. To execute this task, it prefers the select statement. Also, one catching point about Union is that it can remove the duplicate rows from the tables.

What is Union All?

Union All is operated for removing all the rows from a group of two tables.

Difference between Union and Union All

S.No. UNION UNION ALL
1. It has the ability to remove duplicate rows from the table. It cannot remove duplicate rows from the table.
2. Here, the performance is slow because it also eliminates the duplicate rows. Here, the performance is fast because it does not eliminate the duplicate values.
3. Most of the people used Union operators. Hardly users use this operator.
4. Syntax:

SELECT column_list FROM table1

UNION

SELECT column_list FROM table2;

Syntax:

SELECT column_list FROM table1

UNION ALL

SELECT column_list FROM table2;

Keep learning and stay tuned to BYJU’S to get the latest updates on GATE Exam along with GATE Eligibility Criteria, GATE 2024, GATE Admit Card, GATE Application Form, GATE Syllabus, GATE Cutoff, GATE Previous Year Question Paper, and more.

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*