1. xml中拼接
(1)SELECT * FROM tableName WHERE name like concat('%',#{param},'%');
(2) SELECT * FROM tableName WHERE name like '%'||#{param}||'%';
2. 使用 ${...} 代替 #{...}
SELECT * FROM tableName WHERE name like '%${param}%' ;
3. 程序中拼接
Java
String param = "%" + text + "%";
sqlMapper.xml
SELECT * FROM tableName WHERE name LIKE #{param};