mybatis做like模糊查询
来源:互联网 发布:淘宝电热水器 编辑:程序博客网 时间:2024/06/05 19:29
引言
mybatis是一个很好用的持久化框架,允许我们自己写一些复杂的sql,下面我们来说一下当我们要用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 、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}),'%')
阅读全文
0 0
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做模糊查询 like
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做like模糊查询
- mybatis做like模糊查询
- Mybatis LIKE 模糊查询
- MyBatis 模糊查询 like %
- mybatis做like模糊查询的常见三种方法
- Mybatis like 模糊查询问题
- Mybatis like 模糊查询问题
- 博客工具使用练习
- ADTS包头解析
- sqlserver 查询数据分页,类似mysql的limit0,20
- 深度学习之Windows下安装faster-rcnn
- 数字计算
- mybatis做like模糊查询
- 多线程和MsgWaitForMultipleObjects
- 深度学习之Windows下安装caffe及配置Python和matlab接口
- vue环境搭建
- Maven实战(一)--Why Maven
- 【css3】变形
- Codeforces 833B
- 时间转换c++题解
- String类型数字始终保留两位小数