mybatis中循环更新数据的SQL语句⼀、同时更新多条数据的同⼀个字段的同⼀个值
<update id="updatePicturePostId">
update bbs_pictures set post_id = #{postId}
where  user_id = #{userId} and picture_name in
(<foreach collection="pictureName"item="item"separator=",">
#{item}
</foreach>)
</update>
⼆、同时更新多条数据的同⼀个字段的不同值
<update id="updatePicturePostId">
<foreach collection="pictureName"item="item"separator=",">
update bbs_pictures set post_id = #{item.id}
where  user_id = #{userId} and picture_name in #{item.name}
</foreach>)批量更新sql语句
</update>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。