sql - 如何在不使用 Exists 关键字的情况下编写等效查询,以便将其转换为关系代数?
问题描述
我有一个查询:
select daa.*
from Dataa daa
where not exists (select row() from Stuff)
基本上,当 Stuff 中有数据时,查询不会返回任何内容。但是,当 Stuff 为空时,查询将返回 Dataa 中的所有内容。我需要用相同的行为重写这个查询,但没有 exists 关键字,以便我可以将它翻译成关系代数。
我看过的一些资源是:
将 NOT IN 转换为 NOT EXISTS http://mlwiki.org/index.php/Translating_SQL_to_Relational_Algebra#EXISTS_in_the_Where_Clause_.28by_example.29
解决方案
没有几种方法可以编写它Exists
select daa.*
from Dataa daa
where (select 1 from Stuff limit 1) is null
select daa.*
from Dataa daa
where (select count(*) from Stuff) = 0
select daa.*
from Dataa daa
left outer join (select 1 one1 from Stuff)j on 1=1
where j.one1 is null
但我看不出该关键字到底有什么问题。
推荐阅读
- javascript - 代码操作不能通过 javascript 工作
- html - 在 iframe 中隐藏“!DOCTYPE html”
- java - 即使设置了正确的 varProperty() 方法,JavaFX 也无法检索 PropertyValueFactory 中的属性
- javascript - 将一个输入的值复制到jQuery中的另一个输入
- java - Open CV - 从图像中删除彩色区域
- powershell - PowerShell 变量意外为空
- javascript - 运行 npm install 时错误未更改 在附近解析时 JSON 输入意外结束
- javascript - Chart.js标签之间的多个数据
- flutter - 如何在颤动中添加多个链接到firebase的视频播放器
- c# - 不允许在 API 上下文之外运行 Revit 外部应用程序