SQL UNION ALL: The UNION ALL operator is used to combine the result-set of two or more SELECT statements Tables of both the select statement must have the same number of columns with similar data types. It lists ALL records.
Syntax:
SELECT column_name(s) FROM table_name1 UNION ALL SELECT column_name(s) FROM table_name2
SELECT column_name(s) FROM table_name1 UNION ALL SELECT column_name(s) FROM table_name2
Example:
SELECT emp_Name FROM Employees_india UNION ALL SELECT emp_Name FROM Employees_USA
SELECT emp_Name FROM Employees_india UNION ALL SELECT emp_Name FROM Employees_USA
What is the difference between UNION and UNION ALL?
UNION command selects distinct and related information from two tables. On the other hand, UNION ALL selects all the values from both the tables.

0 Comments:
Post a Comment