mybatis 中模糊查询 like
1. like '%${classes.text}%'
在Oracle MySQL中均可使用,且查询正确。亲测可行
2. like '%' || #{classes.text} || '%'
在Oracle中可以使用,且查询正确,但是在mysql中,报错,有乱码,不知道什么原因,未解决,随后补充。
以下是错误信息:
Translating SQLException with SQL state '42000', error code '1064', message [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 'Â
and text like '%' || '山东' || '%'Â
) c' at line 9]; SQL was [] for task [
### Error querying database. Cause: com.mysql.jdbc.exceptions.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 'Â
and text like '%' || '山东' || '%'Â
) c' at line 9
3 like CONCAT('%',#{classes.text},'%')
使用情况 同2.
作者:Frank —— 弗兰克中校
出处:http://www.cnblogs.com/yb666/
本文版权归作者和博客园所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。