mybatis多条件循环修改

请问怎么让下面的修改语句连起来执行,或者说在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'

断桥1
浏览 4722回答 2
2回答

qq_大力_9

<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>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java
MySQL