tangerine7199
tangerine7199

Reputation: 489

Creating Subquery with linking table and source tables mysql

I'm receiving an error when I try to create a query from a linking table and it's two source table. When I ran this in access, it actually worked fine but mysql produced an error stating I needed to add a ( but I don't know where.

    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;

it states

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

but I don't know where to put the additional parenthesis. I tried different combinations of adding parent

Upvotes: 0

Views: 50

Answers (1)

Michael
Michael

Reputation: 5335

 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;

Upvotes: 1

Related Questions