-- 存在即更新,不存在就插入(根据ID)
insert into `vclb_mm_inventory` (`ID_`, `STOCK_ID_`, `ITEM_ID_`, `AMOUNT_`)
values (‘489734716803514367‘, ‘仓库一‘, ‘水杯‘, 44)
ON DUPLICATE KEY UPDATE `AMOUNT_` = `AMOUNT_` + 44;
---------------------
原文:https://blog.csdn.net/zhang135687/article/details/82686991
<!-- 批量更新数据 -->
<update id="updateBatch">
update wd_solr set
name =
<foreach collection="list" item="wdSolr" index="index"
separator=" " open="case id" close="end">
when #{wdSolr.id} then
#{wdSolr.name}
</foreach>
,logo =
<foreach collection="list" item="wdSolr" index="index"
separator=" " open="case id" close="end">
when #{wdSolr.id} then
#{wdSolr.logo}
</foreach>
,timestamp =
<foreach collection="list" item="wdSolr" index="index"
separator=" " open="case id" close="end">
when #{wdSolr.id} then #{wdSolr.timestamp}
</foreach>
where id in
<foreach collection="list" item="wdSolr" index="index"
separator="," open="(" close=")">
#{wdSolr.id}
</foreach>
</update>
原文:https://www.cnblogs.com/xiaoshen666/p/11114443.html