【发布时间】:2017-01-19 11:37:37
【问题描述】:
我正在练习一些 SQL(对此不熟悉), 我有下一张桌子:
screening_occapancy(idscreening,row,col,idclient)
screening(screeningid,idmovie,idtheater,screening_time)
我正在尝试创建一个查询来搜索哪些客户观看了“放映”表中的所有电影并显示他们的 ID(idclient)。
这是我写的(不起作用):
select idclient from screening_occapancy p where not exists
(select screeningid from screening where screeningid=p.idscreening)
我知道这可能不是那么好,所以请试着解释一下我做错了什么。
P.S 我的任务是在做的时候使用 not/exists...
谢谢!
【问题讨论】:
-
子查询中不需要
DISTINCT。
标签: mysql sql not-exists