UNION vs UNION DISTINCT vs UNION ALL
A good way to think about JOINs is to extend our dataset horizontally. A UNION, then, is a way of combining data vertically. Unions combine data sets with the same structure; they simply create a table with rows from both tables.
UNION operators can combine the result set of two or more SELECT statements as long as Each SELECT statement within UNION must have the same number of columns.
The columns must also have similar data types. The columns in each SELECT statement must also be in the same order.
JOIN vs UNION
JOIN
JOIN combines data from many tables based on a matched condition between them.
Several columns selected from each table may not be the same.
It combines data into new columns.
Datatypes of corresponding columns selected from each table can be different.
It may not return distinct columns.
UNION
SQL combines the result set of two or more SELECT statements.
It combines data into new rows
Number of columns selected from each table should be the same.
The data types of corresponding columns selected from each table should be the same.
It returns distinct rows.
UNION