批量更新,不循环,一个sql

前言

如题

实现方式

UPDATE pmi_product_type
        SET
          sort_index = <foreach collection="list" item="item" index="index" separator="" open="Case id" close="END"> WHEN #{item.id} THEN ${index} </foreach>
        WHERE
        id IN <foreach collection="list" item="item" index="index" separator="," open="(" close=")"> #{item.id} </foreach>
发布了48 篇原创文章 · 获赞 14 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/s1441101265/article/details/103972623
今日推荐