mybatis中写模糊查询三种方式
2017-04-06 18:04
447 查看
1. 参数中直接加入%%
param.setUsername("%CD%");
param.setPassword("%11%");
2. bind标签
3. CONCAT
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. CONCAT
where username LIKE concat(concat('%',#{username}),'%')
相关文章推荐
- MyBatis模糊查询的三种方式
- MyBatis学习笔记-06.MyBatis实现模糊查询的三种方式以及在MyBatis中#{}和${}的区别
- [MyBatis]模糊查询LIKE的三种方式
- MyBatis模糊查询的三种拼接方式
- Spring+Mybatis 三种查询映射方式
- Mybatis 中 模糊查询的几种方式
- MyBatis实现模糊查询的几种方式
- mybatis 模糊查询使用 like 的三种方法
- 终极解决sqlserver、MySQL、Oracle三种数据库模糊查询语句,ssm框架mybatis操作数据库
- Hibernate模糊查询三种方式
- mybatis - 条件查询的三种方式
- Mybatis详解(六)模糊匹配查询方式
- Android Sqlite 模糊查询 三种方式
- MyBatis中模糊查询Like语句使用方式
- MyBatis模糊查询(注解方式+映射文件方式)
- android sqlite使用之模糊查询数据库数据的三种方式
- android sqlite使用之模糊查询数据库数据的三种方式
- (4).Mybatis模糊查询MySQL中记录的的常用三种方法
- 终极解决sqlserver、MySQL、Oracle三种数据库模糊查询语句,ssm框架mybatis操作数据库
- MyBatis模糊查询的两种拼接方式