mysql 批量更新 update foreach


第一种方式:一条update
<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>
第二种方式:多条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>
————————————————
版权声明:本文为CSDN博主「Jesse-Xue」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_38809962/article/details/79610348


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM