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 修改过之后

 

 

 

posted @ 2023-02-28 17:02  Carllll  阅读(136)  评论(0)    收藏  举报