mybatis按照条件批量修改

条件批量(场景比如多个用户批量修改用户名,,这样举例比较好理解,这个场景真实情况下不会存在)

<update id = "userName">

    update user

  <set>

      <if>

      user_name = #{userName,jdbcType=TINYINT},

      </if>

      updated_date = now()

  </set>  

      where user_id = #{userId}

    <if test="actNos !=null and actNos.size>0">

     and user_name in

     <foreach collection ="userNames" items="name" separator="," close=")" open="(">

    #{userName,jdbcType = VARCHAR}

    </foreach>

<if>

</update>

posted @ 2020-10-09 18:09  菜鸟厌厌  阅读(1054)  评论(0)    收藏  举报