1.sql中字符串拼接(在使用注解配置中使用)
SELECT *FROM tableName WHERE name LIKE CONCAT(CONCAT('%', #{text}),'%');
2. 使用 ${...} 代替#{...}(慎用,安全问题)
SELECT *FROM tableName WHERE name LIKE '%${text}%';
3.程序中拼接
Java
// StringsearchText = "%" + text + "%";
StringsearchText = newStringBuilder("%").append(text).append("%").toString();
parameterMap.put("text", searchText);
SqlMap.xml
SELECT *FROM tableName WHERE name LIKE #{text};
4.大小写匹配查询
SELECT* FROM TABLENAME WHEREUPPER(SUBSYSTEM) LIKE '%' || UPPER('jz') || '%'
或者
SELECT* FROMTABLENAME WHERE LOWER(SUBSYSTEM) LIKE '%' ||LOWER('jz') || '%'