您可以始终使用“不存在”而不是“不是”?
我有以下模式: 书(ISBN,标题,类型) 已发布(ISBN,PublisherNumber)
查询:发布者的出版商号码是什么,这些发布者专门出版了类型的“计算机科学”书籍?
我尝试使用“不在中”构建查询,并且效果很好。
SELECT p.Publishernumber
FROM published p , book b
WHERE b.ISBN=p.ISBN AND b.Genre = "CS" AND p.publishernumber not in (
SELECT p.publishernumber
FROM Book b , published p
WHERE b.ISBN=p.ISBN AND b.Genre != "CS" );
如何使用“不存在”构建相同的查询?
I have the Following Schema :
Book(ISBN,Title,Genre)
Published(ISBN,Publishernumber)
The Query : What are the publisher numbers of the publishers that exclusively publish books of the genre “Computer Science”?
I tried building the query using "Not in" and it worked fine.
SELECT p.Publishernumber
FROM published p , book b
WHERE b.ISBN=p.ISBN AND b.Genre = "CS" AND p.publishernumber not in (
SELECT p.publishernumber
FROM Book b , published p
WHERE b.ISBN=p.ISBN AND b.Genre != "CS" );
How can i build the same query using "Not Exists" ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要使用
NOT EXISTS
,您需要使用相关子查询。To use
NOT EXISTS
you need to use a correlated subquery.