Oracle 19c SQL

  1. Home
  2. Docs
  3. Oracle 19c SQL
  4. 6 SET Operators
  5. 6.4 INTERSECT

6.4 INTERSECT

Using INTERSECT operator, Oracle displays the common rows from both the SELECT statements, with no duplicates and data arranged in sorted order (ascending by default).

--1st query
SELECT Ename FROM Emp WHERE Deptno = 20;

ENAME
----------
JONES
SCOTT
FORD
SMITH
ADAMS


--2nd query
SELECT Ename FROM Emp WHERE Job = 'CLERK';

ENAME
----------
SMITH
ADAMS
JAMES
MILLER

Using INTERSECT to get the common rows from each component queries. That means INTERSECT will give you distinct rows.

SELECT Ename FROM Emp WHERE Deptno = 20
INTERSECT
SELECT Ename FROM Emp WHERE Job = 'CLERK';

ENAME
----------
ADAMS
SMITH
Was this article helpful to you? Yes No

How can we help?