1.
SELECT XX, XX
FROM TableName
WHERE 1=1
<if test="XX !=null and XX!='' ">
ADN XX LIKE
CONCAT(CONCAT('%', #{XX, jdbcType=varchar}),'%') --模糊查询
</if>
<if test="XX != null and XX != '' ">
AND XX = #{XX, jdbcType=INTEGER}
</if>
</if>
2.
select * from TableName <where>
<if test = 'xx != null '> XX like '%'||#{name}||'%' </if>
<if test='xx!= null '> and XX like '%'||#{code}||'%' </if>
</where>
3.
select * from TableName <where>
<if test = 'xx != null '> XX like "%"#{name}"%" </if>
<if test='xx!= null '> and XX like "%"#{code}"%" </if>
</where>
#{code}会自动加上''