SQL Advanced
 
SQL UNION and UNION ALL
 
UNION
The UNION command is used to select related information from two tables, much like the JOIN command. However, when using the UNION command all selected columns need to be of the same data type.
 
Note: With UNION, only distinct values are selected.
 
 
Employees_India:
 
Employees_USA:
 
 
Using the UNION Command
Example
List all different employee names in INDIA and USA:
 
 
Result
 
Note: This command cannot be used to list all employees in India and USA. In the example above we have two employees with equal names, and only one of them is listed. The UNION command only selects distinct values.
 
UNION ALL
The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.