sql server中的update set from 对应 ORACLE 的写法

首先mssql和oracle两边都支持update set where

update xxx set col = 'xxx' where col = 'sss';

但是SQL SERVER也支持update set from

update xxx set xxx.col = yyy.col from yyy where ......;

ORACLE这边不支持,于是研究了一下有了一种可以代替的sql:

update xxx set xxx.col = (select yyy.col from yyy where ......);

实践之后发现会把xxx.col全变成了yyy.col,于是又有了新的

update xxx set xxx.col = (select yyy.col from yyy where ......)where exists (select 1 yyy.col from yyy where ....);

但是又有一种情况就是xxx.col 有一对多的情况,于是

update xxx set xxx.col = (select yyy.col from yyy where ...... and rownum <= 1)where exists (select 1 yyy.col from yyy where ....);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值