lundi 13 avril 2015

sql list actors who acted in a film before 1900 and also in a film after 2000

so I have 3 tables, actor(id, name), movie (id,name,year) and casts(aid, mid) (which are actor id and movie id). My goal is to select all the actors who acted in a film before 1900 and also in a film after 2000. My query is



select a.id
from actor a, movie m1, casts c1, movie m2, casts c2
where a.id = c1.aid = c2.aid and c1.mid = m1.id and c2.mid = m2.id and
m1.year >2000 and m2.year <1900;


this query took really long time and didnt seem to produce the right result. So someone could please help me?


Aucun commentaire:

Enregistrer un commentaire