Oracle Tutorial

What is Oracle
SQL Keywords

Oracle Wildcards

Oracle Wildcards

Oracle Aliases

Oracle Aliases

MySQL Tutorial

MySQL Tutorial

PL/SQL Tutorial

PL/SQL Tutorial

Oracle Interview Questions

Oracle Interview Questions and Answers


Oracle INTERSECT Operator

In Oracle, the INTERSECT operator takes the results of two queries and returns only rows that appear in both result sets. If a record exists in one query and not in the other, it will be omitted from the INTERSECT results.

Oracle INTERSECT OPERATOR Syntax

To fetch the results of two queries and returns only rows that appear in both result sets, use the following syntax:

Syntax

SELECT col1, col2 FROM tablename1
INTERSECT
SELECT col1, col2 FROM tablename2;

Parameters:

tablename1 & 2: The table name from which you want to achive INTERSECT operator.

.

Oracle INTERSECT OPERATOR example with Single Field

The following Oracle example is using INTERSECT to perform retrive data from both the tables:

Example

SELECT firstName
FROM tblcustomer
INTERSECT
SELECT firstName
FROM tblcustomerloan;

Note:

In the above example, if "firstName" appeared in both the tblcustomer and tblcustomerloan table, it would appear in your result set.