`
445822357
  • 浏览: 743523 次
文章分类
社区版块
存档分类
最新评论

oracle下表关联更新

 
阅读更多

sqlserver中有update set from where用法,oracle中没有这种用法

可以使用如下办法实现

update tbA a

set a.colA=(select b.colB from tbB b where a.colC=b.colC)

where exists (select 1 from tbA a,tbB b where a.colC=b.colC)

删除多余行

delete from tb a where exists(select 1 from tb b where a.name=b.name and a.aaa >b.aaa)

字段名 name aaaa
aa 1
aa 2
bb 1
bb 2
cc 1
dd 2
期望的结果是

字段名 name aaaa
aa 1(2也可以)
bb 1(2也可以)
cc 1
dd 2

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics