一种直接采用函数进行模糊查询,直接在映射文件中书写对应的like语句。

例如:

select * from u_tree ut where ut.node_name like concat(concat(‘%',#{text}),’%')

第二种方式:

使用 ${...} 代替 #{...}

SELECT * FROM tableName WHERE name LIKE '%${text}%'; 

第三种方式:

3. 程序中拼接

Java

// or String searchText = "%" + text + "%";

String searchText = new StringBuilder("%").append(text).append("%").toString();

parameterMap.put("text", searchText);

SqlMap.xml

SELECT * FROM tableName WHERE name LIKE #{text};

相关文章:

  • 2022-12-23
  • 2021-05-04
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案