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.
Example:
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.
Example:
Union, Union All, Intersect, Except
Let’s take an example of these 2 tables,
So finally, here is the output of different operations.