首页 > 数据库技术 > 详细

mysql concat函数进行模糊查询

时间:2017-09-14 15:44:03      阅读:443      评论:0      收藏:0      [点我收藏+]

concat() 函数,是用来连接字符串。

精确查询: select * from user where name=”zhangsan” 
模糊查询; select * from user where name like “%zhang%”

在实际的使用中,条件是作为参数传递进来的。 所以我们使用 concat() 函数

mybatis: 
select * from user where name like concat(“%”, #{name},”%”) 

 

原生SQL:

case when ?1 is null then 1=1 else name like CONCAT(‘%‘,?1,‘%‘) END 

concat(str1,str2,str3,str4,……….); 连接字符串函数,会生成一个字符串 

 

mysql concat函数进行模糊查询

原文:http://www.cnblogs.com/mr-wuxiansheng/p/7520714.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!