首页 > 其他 > 详细

存在及更新

时间:2019-07-01 16:09:26      阅读:111      评论:0      收藏:0      [点我收藏+]

-- 存在即更新,不存在就插入(根据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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!