@MyBatis中使用Update的set和if
UPDATE service_accountuser
<set>
<if test="username != null and username != ''">
username = #{username},
</if>
<if test="userPhone != null and userPhone != ''">
userPhone = #{userPhone},
</if>
<if test="userBrithday != null and userBrithday != ''">
userBrithday = #{userBrithday},
</if>
<if test="realName != null and realName != ''">
realName = #{realName},
</if>
<if test="userEmail != null and userEmail != ''">
userEmail =#{userEmail},
</if>
<if test="userSex != null and userSex != ''">
userSex = #{userSex},
</if>
<if test="remarks != null and remarks != ''">
remarks = #{remarks},
</if>
</set>
WHERE id = #{id}
</update>
update中的set一定要写成<set></set>
的形式,这样才会自动去掉SQL语句中(where关键字前)的最后一个,
号