mybatis like模糊查询问题
2018-02-28 16:52
561 查看
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. bind标签<select id="selectPersons" resultType="person" parameterType="person">
<bind name="pattern" value="'%' + _parameter.username + '%'" />
select id,sex,age,username,password
from person
where username LIKE #{pattern}
</select> 3. CONCATwhere username LIKE concat(concat('%',#{username}),'%')
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. bind标签<select id="selectPersons" resultType="person" parameterType="person">
<bind name="pattern" value="'%' + _parameter.username + '%'" />
select id,sex,age,username,password
from person
where username LIKE #{pattern}
</select> 3. CONCATwhere username LIKE concat(concat('%',#{username}),'%')
相关文章推荐
- Mybatis用like进行模糊查询问题
- mybatis like 模糊查询问题
- Mybatis like 模糊查询问题
- Mybatis LIKE 模糊查询
- 使用模糊查询Like时中文匹配下划线通配符无效的问题
- Mybatis 的like模糊查询
- mybatis 不同数据库的like 模糊查询语句
- Hql语句模糊查询‘like’与传递中文乱码问题
- 模糊查询like的写法问题
- Mybatis plus like查询问题
- mybatis 模糊查询与函数连用%需不需要拼接问题
- Mybatis中oracle、mysql、db2、sql server的like模糊查询
- Mybatis中的like模糊查询
- Mybatis 模糊查询 like【笔记】Could not set parameters for mapping
- MyBatis-模糊查询控制台不报错,但是得到的结果集合确是0的问题解决办法
- mybaitis模糊查询like格式问题解决方法
- MyBatis下动态语句使用like进行模糊查询
- sql查询模糊匹配Like的没数据一个问题
- Mybatis中oracle、mysql、db2、sql server的like模糊查询
- GreenDao模糊(like)查询问题