赞
踩
1、例如搜索‘小’,则返回三条记录
2、例如搜索 ‘狗’ ‘鸟’ 则返回两条记录
1、拼接条件
public String getQuery(List<String> names) {
if (CollectionUtils.isNotEmpty(names)) {
return String.join("|", names);
}
return null;
}
2、mybatis 写法
<select id="findListByNames" resultType="com.entity.HtTest" parameterType="java.lang.String">
select * from ht_test
<where>
<if test="name != null">
and name REGEXP #{name}
</if>
</where>
</select>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。