Intersect Except Query: by Neil A. Basabe
Intersect Except Query: by Neil A. Basabe
By
Neil A. Basabe
1
INTERSECT
INTERSECT QUERY is used to combine two or
more CURSORS|SELECT statements, but returns
rows only from the first CURSOR that are
identical to the rows in the second CURSOR|
SELECT statement.
2
Syntax
SELECT column list
FROM table-name
WHERE condition
INTERSECT
INTERSECT
5
INTERSECT – Example # 2
SELECT e.empno, e.lastname, e.job, e.workdept, p.projno, p.projname
FROM EMPLOYEE e JOIN PROJECT p
ON e.empno=p.respemp
WHERE e.workdept BETWEEN 'A00' and 'D11'
INTERSECT
6
EXCEPT
EXCEPT QUERY is used to combine two or more
CURSORS|SELECT statements, but returns rows
from the first CURSOR that are not found in the
rows of the second CURSOR|SELECT statement.
7
Syntax
SELECT column list
FROM table-name
WHERE condition
EXCEPT
EXCEPT
10
EXCEPT – Example # 2
SELECT e.empno, e.lastname, e.job, e.workdept, p.projno, p.projname
FROM EMPLOYEE e JOIN PROJECT p
ON e.empno=p.respemp
WHERE e.workdept BETWEEN 'A00' and 'D11'
EXCEPT
11
Laboratory Exercises
12