1.模糊查询
使用$符号,有点像EL表达式,用在单引号里面的,强制理解为一个变量
select * from EMP where ENAME like ''A";
<select id="queryEmpByName" parameterType="String" resultType="com.company.entities.Emp">
select * from EMP where ENAME like '%${id}%'
</select>
但是,以上的方法有误,解决方法,在dao层传递字符串: "%"+name+"%"
public List<Emp> queryEmpByName(name){
SqlSession sqlSession =MyBatisHelper.getSqlSession();
String statement="com.company.entities.queryEmpByName";
List<Emp> emps =sqlSession.selectList(statement,"%"+name+"%");
sqlSession.close();
return emps;
}