mybatis中模糊查询like拼接问题
<select id="getUsersByFuzzyQuery" parameterType="User" resultType="User">
select <include refid="columns"/> from users
<where>
<!--
方法一: 直接使用 % 拼接字符串
-->
<if test="name != null">
name like "%"#{name}"%"
</if>
<!--方法二: 使用concat(str1,str2)函数将两个参数连接 -->
<if test="phone != null">
and phone like concat(concat("%",#{phone}),"%")
</if>
<!--方法三: 使用 bind 标签-->
<if test="email != null">
<bind name="pattern" value="'%'+email+'%'"/>
and email like #{pattern}
</if>
</where>
</select>