mybatis模糊查询

来源:互联网 发布:化工专业英语翻译软件 编辑:程序博客网 时间:2024/06/08 08:13

1、第一种用法:

<select id="getRolesByRoleName" resultMap="UnionResultMap">
    select * from ups_sys_role where role_name like CONCAT(CONCAT('%', #{roleName,jdbcType=VARCHAR}), '%')
</select>

2、第二种用法:

     在传递参数的时候,加上%

       controller层:List<UpsSysRole> roleInfos = authService.getRolesByRoleName("%"+roleName+"%");

      mapper.xml: 

            <select id="getRolesByRoleName" resultMap="UnionResultMap">
            select * from ups_sys_role where role_name like #{roleName,jdbcType=VARCHAR}
        </select>

1 0
原创粉丝点击