mybatis批量修改

使用mybats经常要用到批量修改或者删除,贴出批量修改的代码。如果是批量删除,可将update换成delete。

<update id="changestatus" parameterType="String">
        update apply_for_maintenance set status= 1 where
        afmid in
        <foreach item="afmid" index="index" collection="afmids"
            open="(" separator="," close=")">
            #{afmid}
        </foreach>
  </update>

其中使用"#"或者是"$",具体可以根据前台传的参数是否带有单引号而决定,也可以参考:http://blog.csdn.net/kobi521/article/details/16941403,这里有对"$"和"#"号的使用

原文地址:https://www.cnblogs.com/lengxiaofeng/p/6888167.html