CS50 Pset 7 13.sql, I can't solve it, nested sqlite3 database

后端 未结 5 894
感动是毒
感动是毒 2020-12-11 14:10

DataBase movies.db

tables

directors (movie_id, person_id)

movies (id, title, year)

people

5条回答
  •  孤城傲影
    2020-12-11 14:26

    I did it without using any Join, just nesting the conditions.

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

提交回复
热议问题