mysql mapper.xml中 批量更新

  <update id="batchUpdate" parameterType="java.util.List">
    UPDATE
        product
    SET remainder_cansale_rushbuy_store = 
        CASE
        <foreach collection="list" item="item" index="index">
              WHEN id = #{item.id} THEN remainder_cansale_rushbuy_store - #{item.remainderCansaleRushbuyStore}
        </foreach>
        END
    WHERE 
        id IN
            <foreach collection="list" index="index" item="item" open="("separator="," close=")">
                #{item.id}
            </foreach>
  </update>

猜你喜欢

转载自blog.csdn.net/qq_31024823/article/details/86176466