1. 参数中直接加入%%
param.setusername("%cd%"); param.setpassword("%11%"); <select id="selectpersons" resulttype="person" parametertype="person"> select id,sex,age,username,password from person where true <if test="username!=null"> and username like #{username}</if> <if test="password!=null">and password like #{password}</if> </select>
2. bind标签
<select id="selectpersons" resulttype="person" parametertype="person"> <bind name="pattern" value="'%' + _parameter.username + '%'" /> select id,sex,age,username,password from person where username like #{pattern} </select>
3. concat
where username like concat(concat('%',#{username}),'%')
以上所述是小编给大家介绍的mybatis中的like模糊查询功能,希望对大家有所帮助
如对本文有疑问, 点击进行留言回复!!
集合框架——Map、泛型以及Collection算法常用方法
Elasticsearch 升级 7.x 版本后,我感觉掉坑里了
Mybatis的插件运行原理以及如何编写一个Mybatis的插件
网友评论