select * from temp where aa+bb not in (select cc+bb from temp1)
select * from temp where not exist (select * from templ)
select * from temp where not exists(select * from temp1 where temp1.cc=temp.aa and temp1.dd=temp.bb)改了一下字段
楼上那条SQL没问题.可以...但如果在ORACLE里就有问题了.. 请楼下的回答在ORACLE里的处理.谢谢 我的处理方法: select * from temp where aa+bb not in (select cc+bb from temp1) 但如果字段多了,就有问题了.
如果字段多了的话可能就要考虑是不是设计上的问题了 在Oracle里 + 可以做连接符号吗??俺平时是这么用 select * from temp where aa||bb not in (select cc||bb from temp1) 楼主的意思好象只是a<>c,b<>d 那么用应该就可以满足了啊 select temp.* From temp,temp1 where temp1.cc<>temp.aa and temp1.dd<>temp.bb
我的意思如果这道题在ORACLE里,但不用连接符的这种处理方法,那么在ORACLE里应该怎么处理.
select * from temp where (temp.aa + temp.bb) not in (select (d.aa+d.bb)as d_ab from(select temp.aa,temp.bb from temp inner join temp1 on temp.aa = temp1.cc and temp.bb = temp1.bb)as d)
select * from temp where not exists(select * from temp1 where temp1.cc=temp.aa and temp1.bb=temp.bb and temp1.cc=temp.bb and temp1.bb=temp.aa)
select * from( select * from temp union all select * from temp1 )a group by aa,bb having count(*)=1
上面得到的結果是: 1111 1111 2222 2222 3333 3333 -------------------------------------------------但是還有點問題,如果某一記錄也在temp1中唯一存在,記錄也被選出來。所以要改一下 select * from (select distinct * from temp union all select * from( select * from temp union all select * from temp1 )a group by aa,bb having count(*)=1 )b group by aa,bb having count(*)>1真正你要的答案是這個, 結果: 1111 1111 2222 2222 3333 3333
select * from temp where aa+bb not in (select cc+bb from temp1)
请楼下的回答在ORACLE里的处理.谢谢
我的处理方法:
select * from temp where aa+bb not in (select cc+bb from temp1)
但如果字段多了,就有问题了.
在Oracle里 + 可以做连接符号吗??俺平时是这么用
select * from temp where aa||bb not in (select cc||bb from temp1) 楼主的意思好象只是a<>c,b<>d
那么用应该就可以满足了啊
select temp.* From temp,temp1 where temp1.cc<>temp.aa and temp1.dd<>temp.bb
select * from temp
union all
select * from temp1
)a group by aa,bb having count(*)=1
1111 1111
2222 2222
3333 3333
-------------------------------------------------但是還有點問題,如果某一記錄也在temp1中唯一存在,記錄也被選出來。所以要改一下
select * from
(select distinct * from temp
union all
select * from(
select * from temp
union all select * from temp1
)a group by aa,bb having count(*)=1
)b group by aa,bb having count(*)>1真正你要的答案是這個,
結果:
1111 1111
2222 2222
3333 3333