select name from area where id like "%"#{id}"%"
这样写为什么不对啊
select name from area where id like CONCAT(CONCAT('%', #{id}), '%');
试一下
select name from area where id like '%"#{id}"%'
单引号不占用外部语言环境
需要修改为单引号,如下:
select name from area where id like '%'||#{id}||'%'
如果输入参数是实体类,那么需要这样写,加上字段的类型:
select name from area where id like '%'||#{实体类.id,jdbcType=VARCHAR}||'%'
1、MySQL :LIKE CONCAT('%',#{id},'%' ) 或者 LIKE CONCAT('%',‘${id}’,'%' )
2、oracle:LIKE '%'||#{id}||'%'