MySQL数据库,利用concat函数即可,MySQL不用能||连接字符串

mapper.xml

  select * from tb_content_category where title like concat('%',#{paramMap.TITLE, jdbcType=VARCHAR},'%')

 

Oracle数据库,利用concat函数或者||,Oracle数据库利用concat函数时,需要嵌套concat,因为Oracle的concat函数每次只能连接两个字符串

mapper.xml

  select user_account, full_name from tm_user where full_name like '%'||#{paramMap.TITLE, jdbcType=VARCHAR}||'%'
或者
  select user_account, full_name from tm_user where full_name like concat(concat('%',#{paramMap.TITLE, jdbcType=VARCHAR}),'%')

 

或者直接在传入参数时,将需要模糊查询的参数前后加上%

 

相关文章:

  • 2022-01-31
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2021-08-02
  • 2021-10-04
  • 2021-11-07
猜你喜欢
  • 2022-12-23
  • 2022-02-02
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案