zoukankan      html  css  js  c++  java
  • mybatis中模糊查询的方式

    
    
    <!--Mapper.xml中如何进行模糊查询-->
        <sql id="brand_columns">
                 id, name, firstChar,brandName
        </sql>
        <select id="selectBrand" parameterType="com.lf.Brand" resultType="com.lf.Brand">
            select <include refid="brand_columns"/> from tb_brand
            <where>
                <!-- 直接使用 % 拼接字符串 -->
                <!-- 错误写法 "%#{name}%",正确写法: "%"#{name}"%",即#{name}能够正确解析出来,前后再拼上%即可-->
                <if test="name != null">
                    name like "%"#{name}"%"
                </if>
                <!concat(str1,str2)函数将两个参数连接 -->
                <if test="firstChar != null">
                    and first_char like concat(concat("%",#{firstChar}),"%")
                </if>
                <! bind 标签,对字符串进行绑定,对绑定后的字符串使用 like 关键字进行模糊查询 -->
                <if test="brandName != null">
                    <bind name="likeBrandName" value="'%'+brandName+'%'"/>
                    and brand_name like #{brandName}
                </if>
            </where>
        </select>
    
    
    
     
  • 相关阅读:
    js的元素对象
    js实现在末尾添加节点
    js实现点击增加文本输入框
    js的DOM对象
    js其它
    js实现99乘法表
    js
    http的六种请求方法
    11.进制
    10.Debug
  • 原文地址:https://www.cnblogs.com/flgb/p/10182805.html
Copyright © 2011-2022 走看看