I have two tables:actors and movies, and a third table role, which connects them. ActorId is the primary key for actors. MovieCode is the primary key for the movies table. I have a page of an actor where I need to show the date when the movie was published, the name of the movie and the role of the actor. My query is:
SELECT mo.date, mo.title, role.roleDescription
FROM movies mo, role
inner join actors
on role.actorId=actors.actorId
inner join movies
on role.movieCode=movies.movieCode
where role.actorid=2
The query returns me the Cartesian product. What could be the problem?Thank you in advance!
Try this one ,since you want to select the movies and roles of actor for a specific actor you can skip the join on actor table, also in your query you are joining movies two times