Home > other >  Why does this line of code in SQL not work?
Why does this line of code in SQL not work?

Time:09-02

SELECT * FROM people 
WHERE id = (SELECT person_id FROM stars WHERE movie_id = (SELECT id FROM movies WHERE year = 2004))
ORDER BY birth;

CodePudding user response:

I think that you could solve your problem by changing the = to IN statement.

SELECT * FROM people 
WHERE id IN (SELECT person_id FROM stars WHERE movie_id IN (SELECT id FROM movies WHERE year = 2004))
ORDER BY birth;

An example of your table and data would be really helpful.

Hopefully i got your idea right!

  •  Tags:  
  • sql
  • Related