mysql模糊查詢的字符串拼接

mybatis中模糊查詢的方式第一種(和打印的sql)

 @Select("select * from user where name like '%${value}%' ")
List<User> queryLikeByName(String data);
// select * from user where name like '%李%'


mysql中的字符串連接函數
concat(str1,Str2..)
返回的結果連接產生的字符串(如果是數字也會按照字符串拼接處理))
參數 爲null,則返回null
select concat("11","22","33")from user;
select concat("11",22,33)from user;
記過都是112233

mysql的concat函數在連接字符串的時候,只要其中一個是null,


mysql中的字符串連接函數
concat(str1,Str2..)
 @Select("select * from user where name like concat('%',#{date},'%')")
 List<User> queryLikeByName(String data);
 select * from user where name like concat('%',?,'%')
 李(String)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章