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 scaled to 90%
Example using the EXISTS approach:
Suppose we have two database tables with the names Customers and Suppliers as shown below:
Image scaled to 70%
Image scaled to 70%
Now we want to find the common customers who are also suppliers.
Database Exercise
Database Schema:
-- Database schema would be rendered hereExercise Script:
-- Exercise script would be rendered hereAvailable actions: Execute
Execution of the above query will give the following result:
Image scaled to 60%
Last updated on