set语句有个逗号会报错 这个要怎么解决
来源:4-4 用户注册-后端代码实现-2

肖小小
2019-10-03
<update id="update" parameterType="User">
update user
<set>
<if test="name!=null">
name=#{name},
</if>
<if test="phone!=null">
phone=#{phone},
</if>
<if test="aboutme!=null">
aboutme=#{aboutme},
</if>
<if test="password!=null">
password=#{password},
</if>
<if test="avatar!=null">
avatar=#{avatar},
</if>
<if test="type!=null">
type=#{type},
</if>
<if test="enable!=null">
enable=#{enable},
</if>
<if test="agencyId!=null">
agency_id=#{agencyId}
</if>
where id=#{id}
</set>
</update>
更新语法后面set if判断语句后面有个, 但是如果agencyId为空
语句变成
update set name = “xiaoxiao”, where id=1
set语句有个逗号会报错 这个要怎么解决
写回答
1回答
-
格鲁
2019-10-06
这个逗号问题mybatis是会自动解决的,不知道你是触发什么报的错
00
相似问题