Union V/S Join In SQL

In this blog, we will learn about the differences between Union and Joins in SQL. Union and Join, both are used to combine the data from two or more tables.

Union and Join are both used to combine data from two or more tables. 

The main difference between them is in the way the data is combined.

How Union combines the rows

Union combines the data into new rows like in the pictures. When you use ‘Union’ for combining two tables, then the data of the second table gets added to the first one after the rows of the first table and so on.


Union combines the rows


How JOIN combines the rows

Join combines the data of the columns like below. When you JOIN two tables, the first set of rows shows the first table data and in the same row, the next set data from another table will be reflected.


JOIN combines the rows


Union, Union All, Intersect, Except

Let’s take an example of these 2 tables,

Union, Union All, Intersect, Except


So finally, here is the output of different operations.

Union, Union All, Intersect, Except