條件批量(場景比如多個用戶批量修改用戶名,,這樣舉例比較好理解,這個場景真實情況下不會存在)
<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>