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}),'%')

Mybatis中的like模糊查询的更多相关文章

  1. mybatis中根据日期模糊查询

    首先设置起始日期startDate和结束日期endDate,数据库中日期字段为achive_time,表名为dos_dossier<select id="getDossiers&quo ...

  2. Mybatis中的like模糊查询四种方式

    1.  参数中直接加入%% param.setUsername("%CD%"); param.setPassword("%11%"); <select i ...

  3. MyBatis Plus之like模糊查询中包含有特殊字符(_、\、%)

    传统的解决思路:自定义一个拦截器,当有模糊查询时,模糊查询的关键字中包含有上述特殊字符时,在该特殊字符前添加\进行转义处理. 新的解决思路:将like 替换为 MySQL内置函数locate函数 参考 ...

  4. 【Mybatis】【3】mybatis Example Criteria like 模糊查询

    正文: 在Java中使用Mybatis自动生成的方法,like需要自己写通配符 public List<TableA> query(String name) { Example examp ...

  5. mybatis框架入门程序:演示通过mybatis实现数据库的模糊查询操作

    1. mybatis的基本准备操作见我的上一篇博文:https://www.cnblogs.com/wyhluckdog/p/10149480.html 2. 根据用户名查询用户信息: (1)映射文件 ...

  6. Mybatis使用MySQL进行模糊查询时输入中文检索不到结果

    Mybatis使用MySQL进行模糊查询时输入中文检索时,需要在jdbcURL后增加参数   ?useUnicode=true&characterEncoding=UTF-8

  7. MyBatis 中两表关联查询MYSQL (14)

    MyBatis 中两表关联查询MYSQL 1.创建数据库表语句 2.插入测试数据 3.pom文件内容 <?xml version="1.0" encoding="U ...

  8. mybatis Example Criteria like 模糊查询

    用Mybatis代码生成工具会产生很多个XXXExample类,这些类的作用是什么? 查阅了很多资料,在这里总结归纳一下 简介XXXExample类用于构造复杂的筛选条件 它包含一个名为Criteri ...

  9. jdbc中如何实现模糊查询

    情况如何 再利用jdbc执行sql语句的时候,对于其他的句子的执行没什么太大的问题:加上占位符,然后设置占位符的值. 但是在模糊查询的时候,一直都写不对,这里提供了两种可选的解决办法,以供参考. 解决 ...

随机推荐

  1. mysql莫名的主键重复

    REPAIR TABLE t_car_type; OPTIMIZE TABLE t_car_type; 可解决问题

  2. qs库使用

    1.npm地址 https://www.npmjs.com/package/qs 2.概述 将url中的参数转为对象: 将对象转为url参数形式 3.示例 import qs from 'qs'; c ...

  3. Shell脚本之:for

    与其他编程语言类似,Shell支持for循环. for循环一般格式为: for 变量 in 列表 do command1 command2 ... commandN done 列表是一组值(数字.字符 ...

  4. SQL存在一个表而不在还有一个表中的数据

    select a.id,a.oacode,a.custid,a.custname,a.xsz,a.salename,a.communicationtheme,a.communicationproper ...

  5. Spring学习十二----------Bean的配置之@ImportResource和@Value

    © 版权声明:本文为博主原创文章,转载请注明出处 @ImportResource -引入XML配置文件 @Value -从配置文件中获取值 实例 1.项目结构 2.pom.xml <projec ...

  6. hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibernate.domain.Employee1错误

    hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibern ...

  7. Nginx 经验小结

    chmod 777 永远不要 使用 777,有时候可以懒惰的解决权限问题, 但是它同样也表示你没有线索去解决权限问题,你只是在碰运气. 你应该检查整个路径的权限,并思考发生了什么事情. 把 root ...

  8. vue-cli3.0升级失败,vue-cli卸载不掉,vue-cli升级不了3.0

    https://juejin.im/post/5bf7d67c51882518805acb1a vue-cli3.0 使用图形化界面创建和管理项目

  9. CSS定位细节

    记住此三句话,很好的解决了关于浮动方面的问题: 1.浮动的元素对于没有设置浮动的元素来说是不存在的,浮动的元素将会覆盖没有浮动的元素 如图:先让d1浮动在left ,d2位置不浮动,d1覆盖了d2之上 ...

  10. 【题解】[CJOI2019]Cipher

    [题解][CJOI2019]Cipher 题目描述 给定你\(p\)进制数\(s\),\(p \le 9+26\),求对于十进制数\(k\),求\(k^s \equiv ? \mod m\) 数据范围 ...