求大神!使用后ibatis模糊查询报错
如果只有上面一个条件的话,正常,但是一旦多写了一个就报错
<select id="getGoodsByKeyword" parameterClass="string" resultClass="goods">
<!-- select * from goods where goodName like CONCAT('%', #name#, '%')-->
select * from goods
<dynamic prepend="WHERE">
<isNotEmpty>
goodName like CONCAT('%', #name#, '%')
</isNotEmpty>
<!--<isNotEmpty prepend="OR">
describe like CONCAT('%', #name#, '%')
</isNotEmpty>-->
<isNotEmpty prepend="AND">
type like CONCAT('%', #name#, '%')
</isNotEmpty>
</dynamic>
</select>
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 'type like CONCAT('%', '??', '%')' at line 1
[解决办法]
没用过CONCAT可以这样写 type like '%'
[解决办法]
#name#
[解决办法]
'%'
[解决办法]
这样写也防注入
[解决办法]
弄明白$$和##
[解决办法]
sql语句把#改成$试试
[解决办法]
select * from goods where goodName like '%$name$%'
或者
select * from goods where goodName like CONCAT(CONCAT('%',#name#),'%')
[解决办法]
你把你这段SQL直接执行下试试
[解决办法]
7楼正解
concat 函数只能连接2个字符串