merge into 批量修改语句

A表通过关联B表 ,去修改A表本身
语法:
 
merge into A
using B on (A.a = B.a)       -- 关联关系
when matched then           -- 当匹配上,则使用该行数据,修改匹配上的字段
update set A.b = B.b
when not matchen then     -- 当没有匹配上,则执行其它操作
insert ...;
 
PS: 1、不能修改关联字段本身
2、B表关联字段不能有重复值
 
示例:

 

meige  into 修改过之后

尽管很渺小,但终究会变得伟大
原文地址:https://www.cnblogs.com/chenbao1012/p/14582676.html