java mybatis 中sql 模糊查询

时间:2022-11-12 22:03:10
示例:

like  concat('%',#{groupName},'%')

//--------------

<select id="findList" resultType="com.thinkgem.jeesite.modules.rule.entity.RuleCombinationModel">
SELECT 
<include refid="cmsGuestbookColumns"/>
FROM t_zg_rule_group a
<where>
a.DELETE_STATUS = 0
<if test="groupNumber!='' and groupNumber!=null ">
and a.GROUP_NUMBER=#{groupNumber}
</if>
<if test="groupName!='' and groupName!=null ">
and a.GROUP_NAME like concat('%',#{groupName},'%')
<!-- concat('%',#{productName},'%') -->
</if>
<if test="groupStatus!='' and groupStatus!=null ">
and a.GROUP_STATUS=#{groupStatus}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.CREATEDON DESC
</otherwise>
</choose>
</select>