oracle最多多少表关联,【 DB_Oracle】Oracle多表关联更新

table1 t1 set t1.c= (select t2.c from table2 t2 where t1.a=t2.a) WHERE EXISTS(SELECT 1 FROM table2 t2 WHERE t2.a = t1.a);

当在t1.a=t2.a的条件下t2查询出多条记录时也会报错,此时可以考虑将t2.c唯一化。

eg1:取满足条件的t2.c的最值

update table1 t1 set t1.c = (select max(t2.c) from table2  t2 where t1.a=t2.a) where exists(select 1 from table2 t2 where t2.a = t1.a);

eg2:取满足条件第一行的t2.c值

update table1 t1 set t1.c = (select t2.c  from table2  t2 where t1.a=t2.a  and rownum =1) where exists(select 1 from table2 t2 where t2.a = t1.a);

参考博文:ORACLE 两表关联更新三种方式

【 DB_Oracle】Oracle多表关联更新

标签:博文   写法   mamicode   常见   one   blog   html   div   sts

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉 本文系统来源:https://www.cnblogs.com/leiblog/p/14044218.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值