首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

merge into 怎么应用多个update

2013-12-19 
merge into 如何应用多个updatemerge into table ausing() b on abwhen matched then update set k1 whe

merge into 如何应用多个update
merge into table a
using
() b on a=b
when matched then
 update set k=1 where;
update set  m=2 where 
when not matched then

如何可以让 when matched then 中使用多个update 语句

[解决办法]

引用:
merge into table a
using
() b on a=b
when matched then
 update set k=1 where;
update set  m=2 where 
when not matched then

如何可以让 when matched then 中使用多个update 语句


merge into table a
using
() b on a=b
when matched then
 update set k=1 , m=2 where;--这样不行么??
 
when not matched then



[解决办法]
引用:
条件不一样,需要更新不同的字段,所以不能这样写

实在不行就分成多个MERGE来写吧
[解决办法]
merge into table a
using
() b on a=b
when matched then
 update set k=(case when a=1 and b=2 then 1 else k end),
            m=(case when a=2 and b=1 then 2 else m end) where...;
  
when not matched then

热点排行