不要用<>啊。可以用 not Exist 来写
解决方案 »
- 一个建立存储过程的问题
- 数据表NUMBER型列中插入double型数据ORA-01426:数字溢出怎么回事?
- 新手发问
- 关于安装oracle9i for redhat9.0 字符集的问题。
- 触发器报错
- 急疯了,把internal的密码弄丢了。
- 大力兄:在.NET里面,用 mydata.Fill(ds); 得到Oracle的存储过程的记录集,抛出一个异常,请帮我看看怎么解决?(
- 如何写Oracle的SQL语句,高效找出同张表某字段值出现在本月而不出现在上个月的记录?
- Oracle中怎么把查出来的一行结果拆分为两行
- ORA-01445无法从不带保留关键字的表的联接视图中选择ROWID或采样
- 请问在那里能下载到POWERDESIGNER软件本身?急!
- 在线求助!
这样写就不会有你说的那种情况了
from retire a,employee b
where a.id=b.id and a.insureid=b.insureid
and (a.id, a.insureid)not in(select id,insureid from adjust where sign<>1)
order by a.id但是这样非常慢
select a.id, a.insureid, a.time, a.name from
retire a,(select b.id, b.insureid from employee b,
adjust c where (b.id(+)=c.id) and (b.insureid(+)=c.insureid)
and (c.sign<>1))tb where (a.id=tb.id) and (a.insureid=tb.insureid)
order by a.id, a.insureid
from retire a,employee b
where a.id=b.id and a.insureid=b.insureid and
not exists(select c.id from adjust c where c.id=a.id and c.insureid=a.insureid and c.sign=1 )
我没有环境,试一下
select a.id ,a.insureid,a.time,b.name
from retire a,employee b
where a.id=b.id and a.insureid=b.insureid and
not exists(select 1 from adjust c where c.id = a.id and c.insureid = a.insureid and c.sign=1)
order by a.id;
select distinct a.id ,a.insureid,a.time,b.name
from retire a,employee b
where a.id=b.id and a.insureid=b.insureid
and (a.id, a.insureid) in(select id,insureid from retire minus select id,insureid from adjust where sign=1)
order by a.id
好象in不如exists快。
而且你差了个NOT吧