vendredi 10 avril 2015

sql select actors play two more distinct role in the same movie

the question is to select actors that played 2 or more distinct roles in the same movie. And I got 3 table, actor (id,name) movie (id,name) and casts(aid,mid) (aid is the actor id and mid is the movie id) I wrote a query like this



select a.name
from actor a, movie m, casts c
where a.id = c.aid and m.id = casts.mid
group by (m.name)
having count(distinct role) > 2;


this didnt print the right result and I didnt see the problem with it. Thanks for the help!


Aucun commentaire:

Enregistrer un commentaire