MyBatis中like的使用

1、参数中直接加入%%
param.setUsername("%CD%");
param.setPassword("%11%");
<select id="selectPersons" resultType="person" parameterType="person">
select id,sex,age,username,password from person where true
<if test="username!=null"> AND username LIKE #{username}</if>
<if test="password!=null">AND password LIKE #{password}</if>
</select>
2、试用CONCAT
where username LIKE concat(cancat('%',#{username}),'%')

 

错误的方式

sql  like '%${skuId}%'

posted @ 2017-02-08 13:53  wbinbin  阅读(250)  评论(0编辑  收藏  举报