这是我想要的
<update id='stoIncrement' parameterType='java.util.Map'>
update DB set
<if test="#{is_increase} == 1">
count=(select max(count) from DB) +1
</if>
<if test="#{is_increase} == 0">
count=(select max(count) from DB) -1
</if>
where store=#{store}
</update>
这里is_increase
是参数映射的键,而不是表的实体。
但是以上方法似乎无效。有人可以在这方面提供帮助。
谢谢
使用这样的设置:
<update id='stoIncrement' parameterType='java.util.Map'>
update DB
<set>
<if test="is_increase !=null and is_increase == 1">
count=(select max(count) from DB) +1 ,
</if>
<if test="is_increase !=null and is_increase == 0">
count=(select max(count) from DB) -1 ,
</if>
</set>
where store=#{store}
</update>