Mybatis like查询的写法

来源:互联网 发布:淘宝关键词提取器 编辑:程序博客网 时间:2024/06/05 20:30

Mybatis 3.2.6

经过尝试,给出三种可靠可用的写法:


select * from person where name  like "%"#{name}"%"


select * from person where name  like '%'||#{name}||'%'


select * from person where name  like '%${name}%'


三种写法对比后,第一种属于预编译SQL,后两种都不是,因此推荐使用第一种写法。


另外


select * from person where name  like CONCAT(#{name},'%')






http://blog.51cto.com/lavasoft/1386870

http://blog.csdn.net/mexican_jacky/article/details/53170717

原创粉丝点击