问题遇到的现象和发生背景
这是利用mybatis-plus写的一个代码,但是like之后总多一个',(单引号)
问题相关代码,请勿粘贴截图
<update id="updateDaily" >
<bind name="likeLeft" value="name+'%'"/>
update province_cases
set value=value+#{add},cure=cure+#{cure},death=death+#{death},add=#{add}
<if test="name != '' and name != null">
where province_cases.name like #{likeLeft}
</if>
</update>
运行结果及报错内容
==> Preparing: update province_cases set value=value+?,cure=cure+?,death=death+?,add=? where province_cases.name like ?
==> Parameters: 3, 3(Long), 3, 3, 山东%(String)
但是之后又出现了:
[dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:
Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add=3
** where province_cases.name like '山东%'' at line 2**
我的解答思路和尝试过的方法
我试过在like之后直接添加#{name},或者字符串拼接,但是最后都会有个单引号
我想要达到的结果
有经验的程序员能说一下怎么改正吗?