Grokking SQL for Tech Interviews
Ask Author
Back to course home

0% completed

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.

Example using the EXISTS approach:

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

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

Execution of the above query will give the following result:

.....

.....

.....

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