The MySQL does not support INTERSECT operator. However you can still achive using join, depending on the complexity of the INTERSECT query. Basically, the INTERSECT operator takes the results of two queries and returns only rows that appear in both result sets.
To fetch the results of two queries and returns only rows that appear in both result sets, use the following syntax:
tablename1 & 2: The table name from which you want to achive
JOINto perform INTERSECT operator in MySQL:
In the above example, the
JOIN is used to achive INTERSECT with MySQL.
You can use MySQL Command Line Client to achive
INTERSECT in MySQL using join. It will look like this: