Wednesday, July 18, 2007

set operator


Set Operator

UNION Returns All distinct rows selected by either query

UNION ALL Returns All rows selected by either query, including all duplicates

INTERSECT Returns All distinct rows selected by both queries

MINUS Returns All distinct rows that are selected by the first SELECT statement and not selected in the second SELECT statement

----------------------------------------------------------------------------

UNION

select job from emp where deptno=10

union

select job from emp where deptno=30

------------------------------

UNION ALL

select job from emp where deptno=10

union ALL

select job from emp where deptno=30

------------------------------

INTERSECT

select job from emp where deptno=10

INTERSECT

select job from emp where deptno=30

------------------------------

MINUS

select job from emp where deptno=10

MINUS

select job from emp where deptno=30

------------------------------

No comments: