我是靠谱客的博主 明理香氛,这篇文章主要介绍mysql 批量更新 update foreach,现在分享给大家,希望可以做个参考。

第一种方式

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

第二种方式

注意 需要在数据库添加 &allowMultiQueries=true 
jdbc:mysql://192.168.1.109:3306/healthmanage?characterEncoding=utf-8&allowMultiQueries=true

    <update id="updateQuestionseleteTempalteList"  parameterType="java.util.List">  
    <foreach collection="list" item="item" index="index">
        update tb_question_template_seleteitem_detail set selectedName=#{item.selectedName}
        where 1=1 and  selectedId =#{item.selectedId  };

    </foreach>      
  </update>


原文链接: http://blog.csdn.net/lishaojun0115/article/details/50395669

最后

以上就是明理香氛最近收集整理的关于mysql 批量更新 update foreach的全部内容,更多相关mysql内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部