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. 【LeetCode】Validate Binary Search Tree ——合法二叉树

    [题目] Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defin ...

  2. Leetcode Array 16 3Sum Closest

    Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...

  3. 工作总结 a标签 <a href="/meetingtheme">Back to List</a> 返回上一级 指向 控制器 默认Index @Html.ActionLink("Edit59", "Edit", new { id = item.ID }) 默认当前控制器

    @Html.ActionLink("Back to List", "Index")  ----  <a href="/doctorinfo&qu ...

  4. TRUNCATE 不能引发触发器

    我在使用phpmyadmin清空时发现这个问题

  5. sigar 监控服务器硬件信息

    转载 http://www.cnblogs.com/jifeng/archive/2012/05/16/2503519.html 通过使用第三方开源jar包sigar.jar我们可以获得本地的信息 1 ...

  6. 【转】php和java之间rsa加密互通

    以下是php封装好的类,引入即可使用 <?php /** * 作者:pjp * 邮箱:vippjp@163.com */ class RSA{ private $privateKey='';// ...

  7. 复习Java虚拟机:JVM中的Stack和Heap

    在JVM中,内存分为两个部分,Stack(栈)和Heap(堆).这里,我们从JVM的内存管理原理的角度来认识Stack和Heap,并通过这些原理认清Java中静态方法和静态属性的问题. 一般,JVM的 ...

  8. win本地配置docker环境

    先上官网链接:https://docs.docker.com/get-started/part2/#introduction 优质入门教程:http://www.docker.org.cn/book/ ...

  9. 【Java并发编程实战】—–“J.U.C”:ReentrantLock之二lock方法分析

    前一篇博客简介了ReentrantLock的定义和与synchronized的差别,以下尾随LZ的笔记来扒扒ReentrantLock的lock方法.我们知道ReentrantLock有公平锁.非公平 ...

  10. Java 学习 day06

    01-面向对象(Static关键字) package myFirstCode; /* 静态:static. 用法:是一个修饰符,用于修饰成员(成员变量,成员函数) 当成员被静态修饰后,就多了一个调用方 ...