Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
INTERSECT
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

INTERSECT

INTERSECT operation returns the common rows between two result sets. MySQL does not natively support the INTERSECT operator, but you can achieve similar results using INNER JOIN or EXISTS clauses.

Image

Example using the EXISTS approach:

Suppose we have two database tables with the names Customers and Suppliers as shown below:

Image
Image

Now we want to find the common customers who are also suppliers.

MYSQL
MYSQL

. . . .

Execution of the above query will give the following result:

Image

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible