Gunay Karaoglu
Gunay Karaoglu

Reputation: 27

Check if the sub-query includes all of the stated values

I'm trying to find movie_ids for movies that both johnny Depp and Helena Bonham Carted played in. I'm using SQLite3 as software and the famous IMDB dataset.

Upvotes: 0

Views: 48

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 415931

SELECT s.movie_id
FROM stars s
INNER JOIN people p ON p.id = s.person_id
WHERE p.name in ('Johnny Depp', 'Helena Bonham Carter')
GROUP BY s.movie_id
HAVING COUNT(DISTINCT p.id) = 2

Upvotes: 1

Related Questions