I'm working on Pset 7 "Movies" and check50 shows an error for 13.sql (list of Kevin Bacon's co-stars) when I submit my code despite running successfully in the IDE.

The exact error message is Error when executing query: too many statements at once and my code is below.

I thought that the issue might be runtime, so I tried indexing two of the joined columns so the query would run faster. When run my code with the INDEX addition in the IDE, I get the same successful output of Kevin Bacon's co-stars but still fail check50 upon submission.

Is there a maximum number of subqueries that check50 can handle? If so, does anyone have suggestions on how to streamline my code?

///Tried including above body of code but still resulted in error///
CREATE INDEX people_index ON people(id);
CREATE INDEX movie_index ON stars(movie_id);
SELECT DISTINCT people.name FROM people
JOIN stars ON stars.person_id = people.id

WHERE stars.movie_id in (

SELECT movies.id FROM movies
JOIN stars ON movies.id = stars.movie_id

WHERE stars.person_id in (

SELECT people.id FROM people
WHERE people.name = "Kevin Bacon" AND people.birth == 1958

AND people.name != "Kevin Bacon";

1 Answer 1


It's not subqueries that are the problem. You're running 3 statements, and only 1 is allowed. You can't add those indexes.

  • Don't know who voted it down, but there was no reason to. You can't feed a sequence of multiple SQL statements through at once. Just do one at a time.
    – Cliff B
    May 24, 2020 at 23:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .