MERGE INTO a
USING b
ON ( a.id = b.id ) -- 条件是 id 相同
WHEN MATCHED THEN UPDATE SET a.name = b.name -- 匹配的时候,更新
WHEN NOT MATCHED THEN INSERT(a.id,a.name) VALUES(b.id, b.name) -- 源表有,目标表没有,插入
2021-08-20 05:21:37
MERGE INTO a
USING b
ON ( a.id = b.id ) -- 条件是 id 相同
WHEN MATCHED THEN UPDATE SET a.name = b.name -- 匹配的时候,更新
WHEN NOT MATCHED THEN INSERT(a.id,a.name) VALUES(b.id, b.name) -- 源表有,目标表没有,插入
下一篇:mysql jdbc