您好,欢迎来到年旅网。
搜索
您的当前位置:首页mybatis xml常用写法-使用like关键字

mybatis xml常用写法-使用like关键字

来源:年旅网

需求:xml中需要在where中拼接like语句

方法1:concat

<where>
    <trim  suffixOverrides="," >
        <if test="id != null and id != ''" >
            and id =  #{id}
        </if>
        <if test="name != null and name != ''" >
            and name like concat('%',#{name},'%')
        </if>
    </trim>
</where>

方法2:${}

<if test="examTypeName!=null and examTypeName!=''">
    and exam_type_name like '%${examTypeName}%'
</if>

方法3:#{}

<if test="examTypeName!=null and examTypeName!=''">
    and exam_type_name like "%"#{examTypeName}"%"
</if>

参考文章

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- oldu.cn 版权所有 浙ICP备2024123271号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务