创建带有链接表和源表的子查询

时间:2019-05-11 02:41:32

标签: mysql mysql-workbench

当我尝试从链接表创建查询时出现错误,它是两个源表。当我在访问权限中运行它时,它实际上运行良好,但是mysql产生了一个错误,指出我需要添加一个(但我不知道在哪里。

    SELECT movie.movie_name, cast.person_id, cast.movie_id, people.first_name
    FROM people INNER JOIN (movie INNER JOIN [cast] ON movie.movie_id = cast.movie_id) ON 
people.person_id = cast.person_id
    GROUP BY movie.movie_name, cast.person_id, cast.movie_id, people.first_name;

它说明

SELECT is not valid at this position. Expecting '(' 

但是我不知道在哪里加上额外的括号。 我尝试了添加父母的不同组合

1 个答案:

答案 0 :(得分:1)

 SELECT movie.movie_name, cast.person_id, cast.movie_id, people.first_name
    FROM people INNER JOIN cast 
    ON people.person_id = cast.person_id
    INNER JOIN movie
    ON movie.movie_id = cast.movie_id
    GROUP BY movie.movie_name, cast.person_id, cast.movie_id, people.first_name;