Oracle: INTERSECT Operator

INTERSECT  is another Operation in SET that helps to return the common values. For example, in mathematics, if we are assume two sets:

a = {1,2,3,4}

b = {2,3,5,6}

The common elements in both set a and b are 2 and 3. That means:

∩ b is {2,3}.

Syntax

Statement
INTERSECT
Statement;

Example

For instance, we want to find the Common entry by Name, Roll_No in Stu and Children table as shown below:

Children table is shown below:

Children

Reffer to the Stu table below:

Stu table

Now , to find the common intersecting elements:

Select Name, Roll_no from Stu
INTERSECT
Select Name, Roll_no from Children;

Output:

INTERSECTION