<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个字符串