Mybatis中做like模糊查询
- 参数中直接加入%%
param.setName("%abc%");
<select selectByName>
SELECT * FROM users WHERE
<if test="name != null">name LIKE #{name}</if>
</select>
- 标签
<select selectByName>
<bind name="pat" value="'%'+_paramter.name+'%'">
SELECT * FROM users WHERE
<if test="name != null">name LIKE #{pat}</if>
</select>
- 这里是列表文本CONCAT
WHERE name LIKE concat(concat('%',#{name}), '%')