mybatis-plus 3.4.3
“Truncated incorrect DOUBLE value”的解决方法主要是这两种:
1、修改了多个列的值而各列之间用逗号连接而不要用and
错误写法示例:update tablename set col1=value1 and col2=value2 where col3=value3;
正确写法示例:update tablename set col1=value1 ,col2=value2 where col3=value3;
<update id="updateYaoInfos">
update mysite_yaoinfos
<set>
<if test="yaoinfos.number !=null and yaoinfos.number !=''">
number = #{yaoinfos.number}
</if>
<if test="yaoinfos.name !=null and yaoinfos.name !=''">
`name` = #{yaoinfos.name}
</if>
因为 name 是mysql 关键字 所以加上着重号 ` , 运行后会报语法错误。
改为:
<update id="updateYaoInfos">
update mysite_yaoinfos
<set>
<if test="yaoinfos.number !=null and yaoinfos.number !=''">
number = #{yaoinfos.number}
</if>
<if test="yaoinfos.name !=null and yaoinfos.name !=''">
and `name` = #{yaoinfos.name}
</if>
又报错误:
Data truncation: Truncated incorrect DOUBLE value:,
最后改为:
<update id="updateYaoInfos">
update mysite_yaoinfos
<set>
<if test="yaoinfos.number !=null and yaoinfos.number !=''">
number = #{yaoinfos.number}
</if>
<if test="yaoinfos.name !=null and yaoinfos.name !=''">
, `name` = #{yaoinfos.name}
</if>
解决。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)