mybatis当中使用like语句非常复杂,再此记录固定格式:
第一种 concat
select * from 表名 where 字段名 like concat(#{catName},'%') --单个百分号
select * from 表名 where 字段名 like concat(concat('%',#{catName}),'%') --前后百分号
第二种 ||(较为直观)
select * from 表名 where 字段名 like '%' || #{catName} || '%'
第三种 instr
instr(字段,‘关键字’)>0相当于 字段like ‘%关键字%’
instr(字段,‘关键字’)=1相当于 字段like ‘关键字%’
instr(字段,‘关键字’)=0相当于 字段not like ‘%关键字%’
select * from 表名 where instr(字段名,#{catName})>0
另:
在oracle当中直接使用sql语句:
https://www.jb51.net/article/222106.htm