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>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM