mybatis做like模糊查询
2015-12-01 11:05
357 查看
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(cancat('%',#{username}),'%')
相关文章推荐
- 语言的口味(taste)
- spring mvc 事务配置,spring 事务配置说明
- MySql实现动态分页
- bgp配置文件出错调试
- 解决端口占用问题
- union和union all的区别(转)
- 每天一个linux命令(20):linux chmod命令
- 图片裁剪问题
- Derby-10.11学习笔记汇总
- RAID详解[RAID0/RAID1/RAID10/RAID5]
- Spring事务管理的三种方式
- leetcode 第三题Longest Substring Without Repeating Characters
- Couldn't find platform family in Info.plist CFBundleSupportedPlatforms or Mach-O LC_VERSION_MIN
- DTCoretext的导入和简单使用------ 国外大牛的图文混排
- Js获取当前日期时间及其它操作
- 自己修改linux系统启动画面
- Hadoop的本地库(Native Libraries)介绍
- 天猫双11前端分享系列(四):大规模 Node.js 应用
- Java基础01 从HelloWorld到面向对象
- 前端开发学习笔记(三)HeadFirst HTML 与 CSS (第二版)