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,……….); 連接字符串函數,會生成一個字符串