在sql中看到如下
截图:
merge into 表1 using 表2 on(.... and ...)
when matched then ....
上图大概样式
那么表达什么意思?
以下内容摘自博文:
https://blog.csdn.net/qq_34745941/article/details/81176140?utm_source=copy
1. 适用场景:'有则更新,无则插入'
2. 好处
(1) 执行 '效率高'
(2) 语法简洁
语法:
merge into 目标表 b
using 源表 a
on (b.字段1 = a.字段1 and b.字段n = a.字段n) -- 必须带 '()'
when matched then -- 整体扫描,匹配时,执行此处
update 子句
when not matched then -- 整体扫描,不匹配时,执行此处
insert 子句;