mybatis 模糊查询使用 like 的三种方法
2018-02-01 13:54
597 查看
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 操作 mysql时,使用 like 关键进行模糊查询的方法
- SQL三种模糊查询方法(LIKE)and (PATINDEX() . CHARINDEX())对比
- 三种模糊查询方法(LIKE)and (PATINDEX() . CHARINDEX())对比
- 使用Mybatis进行模糊查询的几种常用方法
- 使用Mybatis模糊查询方法
- mybatis模糊查询like使用
- MyBatis中模糊查询Like语句使用方式
- Delphi模糊查询[ POS函数和Like SQL语句 ]使用方法
- MyBatis下动态语句使用like进行模糊查询
- 利用MyBatis进行不同条件的like模糊查询的方法
- (4).Mybatis模糊查询MySQL中记录的的常用三种方法
- SqlParameter 使用 like模糊 查询不到结果的解决方法
- [MyBatis]模糊查询LIKE的三种方式
- Mybatis中使用like模糊查询
- mybatis中怎么使用like形成动态模糊查询,错误使用CONCAT拼接sql的看过来
- MyBatis中使用bind标签构造模糊查询失败的解决方法
- 使用C#操作Access参数形式的模糊查询方法
- mybatis like %% 模糊查询防sql 注入
- ibatis中使用like模糊查询
- MyBatis order by 动态参数时或使用Like查询时用$而不是#