首页 > 数据库技术 > 详细

mybatis ~ 批量更新(sql循环)update foreach

时间:2020-03-31 15:21:09      阅读:2312      评论:0      收藏:0      [点我收藏+]

情况1

<update id=""  parameterType="">
    update tb_thread set isDelete=0
    where threadId in ( 
    <foreach collection="list" item="item" index="index" open="" close="" separator=",">
            #{item.threadId}
    </foreach>
            )     
  </update>

情况2

数据源后加:&allowMultiQueries=true

 <update id="updateJdzClassifyDataGroupId"  parameterType="com.macro.mall.project.classify.domain.JdzClassifyData">
        <foreach collection="list" item="item" index="index">
            update jdz_classify_data
            set group_id=#{item.groupId}
            where id=#{item.id};
        </foreach>
    </update>

 

mybatis ~ 批量更新(sql循环)update foreach

原文:https://www.cnblogs.com/wangshuang123/p/12605298.html

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