<update id="batchUpdate" parameterType="java.util.List">
update t_scte_goods
<trim prefix="set" suffixOverrides=",">
update_time=current_timestamp,
<trim prefix="sell_state =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.sellState !=null">
when goods_id = #{item.goodsId} then #{item.sellState}
</if>
<if test="item.sellState == null">
when goods_id = #{item.goodsId} then t_scte_goods.sell_state
</if>
</foreach>
</trim>
<trim prefix="update_time =case" suffix="end,">
<foreach collection="list" item="item" index="index">
when goods_id=#{item.goodsId} then #{item.updateTime}
</foreach>
</trim>
<trim prefix="price =case" suffix="end,">
<foreach collection="list" item="item" index="index">
<if test="item.price !=null">
when goods_id = #{item.goodsId} then #{item.price}
</if>
<if test="item.price == null">
when goods_id = #{item.goodsId} then t_scte_goods.price
</if>
</foreach>
</trim>
</trim>
where goods_id in
<foreach collection="list" item="item" index="index" separator="," open="(" close=")">
#{item.goodsId}
</foreach>
</update>
mybatis 批量update运用case-when语句
最新推荐文章于 2024-09-29 22:38:03 发布