mybatis中的模糊查询,Oracle和MySQL中的concat

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}),'%')

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