Skip to content

UNION :

The UNION command combines the result set of two or more SELECT statements (only distinct values)

1
2
3
select empname,salary from emp
union
select empname.salary from emp2

UNION ALL :

The UNION ALL command combines the result set of two or more SELECT statements (allows duplicate values).

1
2
3
SELECT empname,salary from emp
union all
select empname,salary from emp2

INTERSECT :

The SQL INTERSECT clause/operator is used to combine two SELECT statements, but returns rows only from the first SELECT statement that are identical to a row in the second SELECT statement. This means INTERSECT returns only common rows returned by the two SELECT statements.

1
2
3
Select empname,salary from emp
intersect
select empname,salary from emp2

EXCEPET :

it always displays result in first select query which is not exist in second select query.

select empname,salary from emp except select empname,salary from emp2