如何解决以下情况?
How to solve the following case?
考虑以下问题:
我们有 3 张桌子,
1. Theatre ( theatre_Id, thatre_name )
2. ShowTime ( showTimeId, theatre_Id, movie_id )
3. Movies ( movie_id, movie_name )
现在相同的电影名称也可以有不同的 movieId,这取决于卷轴。
例如:[1,哈利波特],[2,哈利波特],[3,卡尔海盗]
现在我们需要找到在所有影院位置都有放映时间的电影名称吗?
是嵌套关联查询吗?
如果你能更好地表述问题:
What are the names of movies whose theatre list is the same size as the number of theatres?
你得到查询:
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))
考虑以下问题: 我们有 3 张桌子,
1. Theatre ( theatre_Id, thatre_name )
2. ShowTime ( showTimeId, theatre_Id, movie_id )
3. Movies ( movie_id, movie_name )
现在相同的电影名称也可以有不同的 movieId,这取决于卷轴。
例如:[1,哈利波特],[2,哈利波特],[3,卡尔海盗]
现在我们需要找到在所有影院位置都有放映时间的电影名称吗? 是嵌套关联查询吗?
如果你能更好地表述问题:
What are the names of movies whose theatre list is the same size as the number of theatres?
你得到查询:
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))