<update id="batchUpdate" parameterType="java.util.List">
update demo_table
<trim prefix="set" suffixOverrides=",">
field1 =
<foreach collection="list" item="item" open="case " close=" end,">
when field2 = #{item.value2} AND field3 = #{item.value3} then #{item.value1}
</foreach>
field4 =
<foreach collection="list" item="item" open="case " close=" end,">
when field2 = #{item.value2} AND field3 = #{item.value3} then
<choose>
<when test="item.value4 != null">
#{item.value4}
</when>
<otherwise>field4</otherwise>
</choose>
</foreach>
</trim>
<where>
<foreach collection="list" item="item" open="( " separator=") or (" close=" )">
field2 = #{item.value2} AND field3 = #{item.value3}
</foreach>
</where>
</update>
批量更新 多条件 多数据
猜你喜欢
转载自blog.csdn.net/qq_36457575/article/details/86227701
今日推荐
周排行