Combines the result of two or more select statement.
Each Select Statement must have same number of columns and columns must have same data types.
Columns should also be in same order.
Syntax :-
[ Removes the duplicate Values ]
SELECT Column1, Column2, FROM table1
UNION
SELECT Column1, Column2, FROM table2
[ Duplicate Values are retained ]
SELECT Column FROM table1
UNION ALL
SELECT Column FROM table2
Example :-
SELECT ename, job FROM emp1
UNION
SELECT ename, job FROM emp2
We have two tables :-
After use UNION operator we get this table,
a
Each Select Statement must have same number of columns and columns must have same data types.
Columns should also be in same order.
Syntax :-
[ Removes the duplicate Values ]
SELECT Column1, Column2, FROM table1
UNION
SELECT Column1, Column2, FROM table2
[ Duplicate Values are retained ]
SELECT Column FROM table1
UNION ALL
SELECT Column FROM table2
Example :-
SELECT ename, job FROM emp1
UNION
SELECT ename, job FROM emp2
We have two tables :-
After use UNION operator we get this table,
a
0 Comments:
Post a Comment