sql - 我的代码没有比较 Oracle 中的每一行
问题描述
以下是我的代码,我想选择第二个表中不存在
select t.reg,
t.dist,
t.pkey,
t.n_code,
t.sum as s17,
s.sum as s18
from table1 t,
(select *
from table2 t
where t.pkey is not null) s
where t.pkey= s.pkey
and t.reg= s.reg
and t.dist= s.dist
and t.a = 99
and s.a != 99
and t.n_code= 66
and t.n_code = s.n_code
and t.sum > 0
and t.sum not in s.sum --not in is not working i think
and t.reg= 33
and t.dist= 1
t.sum 没有在第二个表的每一行中进行比较,第一个表的值存在于第二个表中,但存在于另一行中。
代码不搜索其他行以及 PL/SQL
解决方案
Not in
不能这样工作。Not in
is的语法t.sum Not in (10,20)
,您也可以使用子查询代替静态值。
但这里Not In
不需要。您可以替换以下内容
and t.sum not in s.sum
和
and t.sum <> s.sum
推荐阅读
- python - 如何在plotly中为图表创建带有换行符的标题
- node.js - 如何更快地检测到与 Firestore 的断开连接?
- java - 在 IntelliJ IDEA 中移动包
- php - 在一个信封中同时举行签字仪式
- c++ - 如何获得全局互斥锁?
- python - 从 CSV 列到字典的匹配值 - python
- python - 从由 pandas.cut() 分箱的 pandas 列中过滤行
- reactjs - react-facebook-login 在桌面浏览器上工作,但在移动设备上抛出“URL Blocked: This redirect failed because the redirect URI is not whitelisted”
- opencl - 导致或解决可能的 AMD 编译器错误
- reactjs - 当使用 React Bootstrap Typeahead 找不到匹配项时为 props 添加值