在用mybatis注解进行模糊查询是,网上说查询语句是:
@Select("select * from t_chushou where (title like CONCAT('%',#{0},'%')")
但是我运行起来结果是这样:
SQL: select * from t_chushou WHERE (title like CONCAT("%",?,"%")
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 '' at line 2
第三方软件直接运行SQL语句,好像‘%’后是没用的,打什么求指教
可以考虑别的办法,比如:
select * from t__chushou where title like #{arg0};
arg0在程序中处理后传进来,即自己拼好串“%arg0%”;
还有一种办法是利用${arg0}动态替换,就不用concat函数了