模糊查詢:java
工做中用到,寫三種用法吧,第四種爲大小寫匹配查詢sql
1. sql中字符串拼接app
SELECT * FROM tableName WHERE name LIKE CONCAT(CONCAT('%', #{text}), '%');ui
2. 使用 ${...} 代替 #{...}spa
SELECT * FROM tableName WHERE name LIKE '%${text}%'; .net
3. 程序中拼接xml
Javablog
// or String searchText = "%" + text + "%";ip
String searchText = new StringBuilder("%").append(text).append("%").toString();字符串
parameterMap.put("text", searchText);
SqlMap.xml
SELECT * FROM tableName WHERE name LIKE #{text};
4. 大小寫匹配查詢
[sql] view plain copy