请问怎么让下面的修改语句连起来执行,或者说在mybatis里怎么根据多个条件的不同值循环修改表中的数据?UPDATE erp_goods_stock_info SET goods_num = goods_num - 2 WHERE stock_key = 'SHK2kgdqJodlFGFNKgF' AND goods_key = 'GDo1Xgageof3WPFyAg' UPDATE erp_goods_stock_info SET goods_num = goods_num - 1 WHERE stock_key = 'SHK2kgdqJodlFGFNKgF' AND goods_key = 'GDTJDvqhfyElnJ5uzO'
2 回答
qq_大力_9
TA贡献1条经验 获得超0个赞
<update id="batchUpdate" parameterType="java.util.List">
update demo_table
set field1 =
<foreach collection="list" item="item" open="case " close=" end">
when field2 = #{item.value2} AND field3 = #{item.value3} then #{item.value1}
</foreach>
<where>
<foreach collection="list" item="item" open="( " separator=") or (" close=" )">
field2 = #{item.value2} AND field3 = #{item.value3}
</foreach>
</where>
</update>
添加回答
举报
0/150
提交
取消