Intersect, Minus keywords are absent in MySql and the workarounds are
- Inner Join, and
- Subqueries or
- Left Join respectively.
Please look into here
Doing INTERSECT and MINUS in MySQL
I have given a shot (though I am a SQL Server guy)
Input:
id_user id_movie
101 1
102 2
102 3
104 4
102 5
107 6
102 2
103 3
109 9
110 2
110 3
The output by using an intersect (if run in SQL Server) will be
id_user
102
110
MySQL compatible queries
Query 1 using Inner join
select distinct a.id_user
from Rating a
join Rating b on a.id_user = b.id_user
where a.id_movie = 2 and b.id_movie = 3
Query 2 using Cross join
select distinct a.id_user
from Rating a, Rating b
where a.id_user = b.id_user
and a.id_movie = 2
and b.id_movie = 3
Query 3 using subquery
Already answered above.