Mysql+Mybatis批量更新

有这样一个页面,需要做一个批量update的操作。

Mysql+Mybatis批量更新_第1张图片


后台sql如下:

<!-- 批量更新rank-->
	<update id="batchUpdateRank" parameterType="Map">  
    	UPDATE help_center
   			SET rank = CASE helpId
   		 	<foreach collection="list" item="obj" index="index">  
	        	WHEN #{obj.helpId} 	THEN #{obj.rank}
   		 	</foreach>
   			END
		WHERE helpId IN
		 <foreach collection="helpIds" item="item" index="index" open="(" separator="," close=")" >  
        	#{item}  
   		 </foreach>
	</update> 


你可能感兴趣的:(mysql,mybatis,批量更新)