Loading, please wait...

Intersect Clause

How To Use Intersect Clause In SQL

 

Introduction:
In this article, you will learn what Intersect clause is and how to use Intersect clause in SQL.

The Intersect clause is used to find the common data between two or more tables. This clause follows the rules of a union operator. If we use this clause, it is must that all the data is set in a series. Like the Union operator, this clause also has two operators. Intersect clause performs as an AND operator means gives the common rows from the each table.

 

Here, we have two tables-

Employee Table

 

 

 

 

 

Query Table

 

 

 

Now, we collect same records in both the tables, according to our condition.

 

Syntax

The syntax of Intersect clause is as follows:

 

select column1, column2... from table1 [where condition] table2 [where condition]

Intersect

select column1, column2.... from table1 [where condition] table2 [where condition]

 

 

Example

 

Step 1: We write our query for Intersect clause.

 

 

 

Now, select and execute this query.

 

Step 2: The output of this query is:

 

 

 

Summary:

Thus, we learned, an intersect clause is used to find the common data between the two or more tables and also learn its use.