merge into 如何应用多个update

hafoo 2013-12-16 04:55:22
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 语句
...全文
1644 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hafoo 2013-12-18
  • 打赏
  • 举报
回复
引用 5 楼 luoyoumou 的回复:
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
太感谢了。
潇洒王子 2013-12-16
  • 打赏
  • 举报
回复
活学活用,学无止境啊
luoyoumou 2013-12-16
  • 打赏
  • 举报
回复
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
luoyoumou 2013-12-16
  • 打赏
  • 举报
回复
如果条件不一样的话,把条件写到“case ... when ...”里去更新不就完了?
CT_LXL 2013-12-16
  • 打赏
  • 举报
回复
引用 2 楼 hafoo 的回复:
条件不一样,需要更新不同的字段,所以不能这样写
实在不行就分成多个MERGE来写吧
hafoo 2013-12-16
  • 打赏
  • 举报
回复
条件不一样,需要更新不同的字段,所以不能这样写
Yole 2013-12-16
  • 打赏
  • 举报
回复
引用 楼主 hafoo 的回复:
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

17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧