用'%${name}%'可以实现模糊查询,但会放开SQL注入漏洞。
<when test="name != null and name!=''">
    AND name like '%${name }%'
</when>

最好的方式,是
Oracle可以用
<when test="name != null and name!=''">
    AND name like '%'||#{name }||'%'
</when>

MySql可以用
<when test="name != null and name!=''">
    AND name like CONCAT('%',#{name},'%')
</when>

相关文章:

  • 2020-11-10
  • 2018-03-16
  • 2018-04-10
  • 2022-01-05
  • 2021-06-14
  • 2022-01-28
  • 2021-12-28
  • 2022-02-16
猜你喜欢
  • 2021-11-02
  • 2021-06-04
  • 2021-11-08
  • 2021-11-19
  • 2021-11-19
  • 2021-11-19
  • 2021-10-08
相关资源
相似解决方案