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