数据库如下:
data:image/jpeg;base64,.............
,其中一位演员名字叫'查理·卓别林(Charlie Chaplin)',我需要它来返回他演过的电影,而我无法获得查询来返回它。
我当前的查询是
actors(PK(AID), name)
movies(PK(MID), name)
actor_role(FK(MID), FK(AID), rolename)
它只返回所有电影,而不是专门针对他表演的电影。
答案 0 :(得分:1)
我认为这是您的查询:
select M.name
from movies M
join actor_role AR on AR.MID = M.MID
join actors A on A.AID = AR.AID
where A.name = 'Charlie Chaplin'
答案 1 :(得分:0)
内部加入:
SELECT movie.name
FROM movies, actors, actor_role
WHERE actors.name = 'Charlie Chaplin' AND
movies.MID = actor_role.MID AND
actors.AID = actor_role.AID
答案 2 :(得分:0)
演员和电影没有关系,必须使用actor_role来加入演员和电影
SELECT movie.name
FROM actor_role as ar
inner join actors as a
on ar.AID = a.AID
INNER JOIN movies as m
ON ar.MID =
WHERE a.name = 'Charlie Chaplin'