Oracle里面使用not exists代替not in的问题

牛麦康纳
博客专家认证
2009-05-17 06:16:55
我原来写了个程序,用了not in去处理,语句如下
select count(*) as col_0_0_ from ETKTLOG_AREA_VIEW etktlogare0_ where ((1=1 ))and(etktlogare0_.STATUS=(1))and((etktlogare0_.SERIAL_NUMBER not in(select device1_.SERIALNUMBER from DEVICE device1_ where (device1_.DEVICETYPE_ID in(select devicetype0_.ID from DEVICETYPE devicetype0_))))or((etktlogare0_.SERIAL_NUMBER is null )))
结果发现特别慢,现在想把not in换成not not exists 怎么就报错了呢?
Hibernate支持not exists吧?我看都编译过来了,就是运行的时候出错了。。。。
高手指点下。
...全文
389 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
sweetBug 2009-05-19
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 APOLLO_TS 的回复:]
使用连接查询.
[/Quote]
支持
money8899 2009-05-19
  • 打赏
  • 举报
回复
up
APOLLO_TS 2009-05-19
  • 打赏
  • 举报
回复
使用连接查询.
牛麦康纳 2009-05-17
  • 打赏
  • 举报
回复
恩!谢谢楼上的,我明天再去公司实验一下啊!
zyhowe 2009-05-17
  • 打赏
  • 举报
回复
select count(*) as col_0_0_
from ETKTLOG_AREA_VIEW a
where STATUS=1
and (
not exists(
select 1 from DEVICE b where SERIAL_NUMBER=a.SERIAL_NUMBER
and exists(select ID from DEVICETYPE devicetype0_
where id=b.DEVICETYPE_ID
)
or SERIAL_NUMBER is null
)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧