CS50 pset7电影Q13

时间:2020-08-19 20:14:29

标签: sql cs50

对于pset7 Q13问题,我的SQL代码正在返回错误:

Result: ambiguous column name: id
At line 1:

不应该这样,因为有一个列名是“ id”。

Q13: 在13.sql中,编写一个SQL查询,以列出曾在凯文·培根也曾出演过电影的所有人的名字。

  • 您的查询应该输出一个表格,其中每个人的名字都只有一列。
  • 数据库中可能有多个名为Kevin Bacon的人。确保只选择出生于1958年的凯文·培根。
  • 凯文·培根本人不应列入结果列表。

SELECT name FROM people, stars WHERE people.id = stars.person_id AND stars.movie_id IN (SELECT id FROM movies, stars, people WHERE movies.id = stars.movie_id AND stars.person_id = people.id AND name = "Kevin Bacon" AND birth = 1958);

已更新:

SELECT name FROM people, stars WHERE people.id = stars.person_id AND stars.movie_id IN (SELECT movies.id FROM movies, stars, people WHERE movies.id = stars.movie_id AND stars.person_id = people.id AND name = "Kevin Bacon" AND birth = 1958) AND name != "Kevin Bacon";

0 个答案:

没有答案