mybatis 批量增删改之-----批量更新

根据ID更新商品编号商品价格
<update id="updateCopeHdxx" parameterType="java.util.List"> update T_JQ_SPHDMBB <trim prefix="set" suffixOverrides=","> <trim prefix="spbh=case" suffix="end,">//注意逗号 <foreach collection="list" item="i" index="index"> <if test="i.spbh != null"> when id= '${i.id}' then #{i.spbh} </if> </foreach> </trim> <trim prefix="spjg=case" suffix="end"> <foreach collection="list" item="i" index="index"> <if test="i.spjg != null"> when id= '${i.id}' then #{i.spjg} </if> </foreach> </trim> </trim> where ( <foreach collection="list" separator="or" item="i" index="index"> id= '${i.id}' </foreach> ) </update>

 

 

posted @ 2018-07-17 16:23  彈指一揮間  阅读(243)  评论(0编辑  收藏  举报