Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Consider the following question: We have 3 tables,

1. Theatre  ( theatre_Id, thatre_name )
2. ShowTime ( showTimeId,  theatre_Id, movie_id )
3. Movies   ( movie_id, movie_name )

Now same movie name can also have different movieId's sort of dependent on the reel.

Eg: [1, HarryPotter], [2, HarryPotter], [3, Pirates of Carr]

Now we need to find movie name which has showtime on all theatre locations ? Is it nested correlated query ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
174 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you better phrase the question:

What are the names of movies whose theatre list is the same size as the number of theatres?

you get the query:

select distinct movie_name
from Movies m
where movie_id in (
    select movie_id
    from ShowTime
    group by movie_id
    having count(distinct theatre_Id) = (select count(*) from Theatre))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...