Mybatis下@Select注解使用模糊查询要使用concat方法拼接%百分号和关键词,案例如下:
package com.xzit.mapper; import com.xzit.entity.Emp; import org.apache.ibatis.annotations.*; import java.util.List; @Mapper public interface EmpMapper { /*按给定地址查询员工*/ @Select("select * from emp where addr like concat('%',#{addr},'%')") List<Emp> selectListByAddr(String addr); /*按照给定地址查询员工*/ @Select("select * from emp where addr like concat('%',#{addr},'%')") List<Emp> selectAddr(String addr); }
参考文章:
https://wenku.baidu.com/view/1ce7023cfc00bed5b9f3f90f76c66137ee064f33.html
标签:like,查询,Mybatis,import,Select,addr From: https://www.cnblogs.com/zengyu1234/p/16589646.html