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


情況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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM