1、直接拼接%%:
<select id="getActiveDatas" parameterType="java.util.Map" resultType="java.util.Map">
select * from tab_test where is_deleted = 0
<if test="frameNo != null and frameNo != '%%'">
and frame_no like '%${frameNo}%'
</if>
</select>
2、定义 一个<bind/>变量:
<select id="getActiveDatas" parameterType="java.util.Map" resultType="java.util.Map">
<bind name="frameNo" value="'%' + _parameter.frameNo + '%'" />
select <include refid="textDatas"/> from tab_test where is_deleted = 0
<if test="frameNo != null and frameNo != '%%'">
and frame_no like #{frameNo}
</if>
</select>
3、使用locate()函数:
<select id="getActiveDatas" parameterType="java.util.Map" resultType="java.util.Map">
select * from tab_test where is_deleted = 0
<if test="frameNo != null and frameNo != ''">
and LOCATE(#{frameNo}, frame_no ) > 0
</if>
</select>
4、使用instr()函数:
<select id="getActiveDatas" parameterType="java.util.Map" resultType="java.util.Map">
select * from tab_test where is_deleted = 0
<if test="frameNo != null and frameNo != ''">
and INSTR(frame_no , #{frameNo})
</if>
</select>