oracle中的exists 和not exists 用法详解

select * 
from (select 0 as id,'050003' as MARKETCODE,'' as SEQCODE,'' as ACCOUNT,'' as ACCNAME,'' as CCADDR,
		max(BALDATE) as BALDATE,'' as CURRENCY,0 as BALANCE,to_number(sum(BALANCEAVAL)) as BALANCEAVAL,
		'' as CKECKSTATUS,max(UPDATEUSER) as UPDATEUSER, max(UPDATETIME) as UPDATETIME,max(CHECKUSER) as CHECKUSER,
		max(CHECKTIME) as CHECKTIME               
	from  srv_koss_accbalance where baldate='20180619' and marketcode='050003' and account!='310066726018150009956' )
where exists (select * from srv_koss_accbalance where  marketcode='050003' and account!='310066726018150009956')

exists():表示()内子查询语句返回结果不为空说明where条件成立就会执行主sql语句,如果为空就表示where条件不成立,sql语句就不会执行。
not existsexists相反。
写法:select * from (SQL查询语句) where exists(SQL查询语句)
exists后面的sql是判断这个大的sql生不生效,生效的话,真正的返回结果是from后面sql的返回结果。
例子:select * from 表名 where exists(判断sql) and 真正执行的where条件

select * from srv_koss_fundinfo x where exists(SELECT *FROM SRV_KOSS_FUNDINFO WHERE FUNDTYPE='6') and FUNDTYPE='3'

参考:https://www.cnblogs.com/liuqiyun/p/6549828.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值