SQL UNION Operator.
The UNION operator is used to combine the result sets of two or more SELECT statements. For UNION, every SELECT statement must have same number of columns with same data type and must be in same order. It will return the distinct values by removing the duplicate rows.
Syntax:
SELECT columnList FROM table1 UNION SELECT columnList FROM table2;
Example:
Output:
SQL UNION ALL Operator.
It works same as UNION operator only difference is that it returns the duplicate rows.
Syntax:
SELECT columnList FROM table1 UNION ALL SELECT columnList FROM table2;
No comments:
Post a Comment