zoukankan      html  css  js  c++  java
  • Mybatis LIKE模糊查询

    1、在代码中拼接好字符串后传入进来

    2、使用CONCAT在xml中拼接字符串:

    <if test="queryParam.keyword != null">
        AND b.appName LIKE CONCAT('%', #{queryParam.keyword}, '%')
    </if>

    3、Mybatis的bind:

    List<RoleEntity> selectBykeyWord(@Param("keyword") String keyword);
        <select id="selectBykeyWord" parameterType="string" resultType="com.why.mybatis.entity.RoleEntity">
            <bind name="pattern" value="'%' + keyword + '%'" />
            SELECT
            *
            FROM
            t_role
            WHERE
            role_name LIKE #{pattern}
            OR
            id LIKE #{pattern}
            OR
            role_type like #{pattern}
        </select>
  • 相关阅读:
    poj 2388
    BUAA 1489
    poj 2524
    poj 2109
    poj 2503 Babelfish
    poj All in All
    poj 1611 The Suspects
    poj 2299
    poj 1328
    hdu 1008 Elevator
  • 原文地址:https://www.cnblogs.com/langren1992/p/9682853.html
Copyright © 2011-2022 走看看