码迷,mamicode.com
首页 > 其他好文 > 详细

mybatis模糊查询

时间:2018-03-29 00:03:13      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:模糊   查询   匹配   nbsp   body   log   自动   col   tis   

原先查询片段如下,自动生成的代码默认只能全字段匹配查询

 <if test="hobby != null and hobby != ‘‘">
       and HOBBY = #{hobby}
 </if>
 <if test="code != null and code != ‘‘">
       and CODE = #{code}
 </if>

现要对code字段的值实现模糊查询,如下

 <if test="hobby != null and hobby != ‘‘">
        and HOBBY = #{hobby}
 </if>
 <if test="code != null and code != ‘‘">
        and CODE like concat(concat(‘%‘,#{code}),‘%‘) 
 </if>

 

mybatis模糊查询

标签:模糊   查询   匹配   nbsp   body   log   自动   col   tis   

原文地址:https://www.cnblogs.com/zjfjava/p/8666398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!