Syntax of UNION in SQL-
SELECT <column_name(s)> FROM table1
UNION
SELECT <column_name(s)> FROM table2;
Example of UNION in SQL-
SELECT City FROM Customers
UNION
SELECT City FROM Suppliers;
Syntax of UNION ALL in SQL-
SELECT <column_name(s)> FROM table1
UNION ALL
SELECT <column_name(s)> FROM table2;
Example of UNION ALL in SQL-
SELECT City FROM Customers
UNION ALL
SELECT City FROM Suppliers;
–It will return the cities from both Customers and Suppliers table.