MySql模糊查询 concat()函数

在sql语句之中,查询根据场景要求不同有两种方式,精准查询与模糊查询:

 

精确查询语法:select * from student where name="zhangsan";

模糊查询语法:select * from student where name like "%*san%";

 

而在java开发时,往往查询条件是作为参数传递过来的,所以有了concat()函数:

 

select * from student where name like concat("%",#{name},"%");

可以看出concat()函数的作用为连接字符串。

 

posted @ 2020-03-19 14:24  弗乱  阅读(5037)  评论(0编辑  收藏  举报