第一种 直接用${} 进行字符串拼接 但是有SQL注入的风险.所以不推荐使用
select * from user where username like '%${value}%'
第二种 使用#{value} 然后在业务层java代码中将 % 拼接好
select * from user where username like #{value}
第三种 推荐使用 concat() 函数
注意 concat 函数 mysql 和Oracle 语法是不一样的
mysql中 concat 可以拼接多个
Oracle 只能拼接两个 在前后都需要拼接 % 或者_ 的时候 需要 concat(concat('%',#{value}),'%')
下面代码块 是mysql的写法
select * from user where username like concat('%',#{value},'%')