The problem is that you're joining to movies
twice: once as mo
, and once as movies
. mo
is never mentioned in any ON
clause or WHERE
clause, so you never filter out any of the values of mo
. To fix it, just remove the movies mo,
part, and change the fields in your SELECT
-list to use movies
instead of mo
:
SELECT movies.date, movies.title, role.roleDescription
FROM role
inner join actors
on role.actorId=actors.actorId
inner join movies
on role.movieCode=movies.movieCode
where role.actorid=2
Also, you don't really need the join to actors
, since you're not selecting anything from actors
and you already know what value of actorid
you want. So removing that, and restructuring a bit for clarity:
SELECT movies.date,
movies.title,
role.roleDescription
FROM movies
JOIN role
ON role.movieCode = movies.movieCode
WHERE role.actorid = 2
;