第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > myBatis 模糊查询like拼接

myBatis 模糊查询like拼接

时间:2020-05-30 04:51:08

相关推荐

myBatis 模糊查询like拼接

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>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。