zoukankan      html  css  js  c++  java
  • Mybatis模糊查询(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拼接sql

    where username LIKE concat(concat('%',#{username}),'%')
    文章仅供参考,转载请注明出处。
    不怕千万人阻挡,只怕自己投降。
  • 相关阅读:
    function函数
    for的衍生对象
    前端发展史
    字符串替换
    正则
    DOM和BOM的区别与联系
    BOM
    DOM
    css单位分析
    API and Web API
  • 原文地址:https://www.cnblogs.com/jakeylove3/p/7799399.html
Copyright © 2011-2022 走看看