在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()函數的作用為連接字符串。