1、if ... else 的写法:
<select id="selectSelective" resultMap="xxx" parameterType="xxx">
select * from table
<where>
columName=#{xxx}
<choose>
<when test="xxx !=null and xxx != ''">
and xxx like concat(concat('%', #{xxx}), '%')
</when>
<otherwise>
and xxx like '**%'
</otherwise>
</choose>
</where>
</select>
2、!=null 、==null的写法:
<select id="selectSelective" resultMap="xxx" parameterType="xxx">
select * from table where column is not null;
</select >
<select id="selectSelective" resultMap="xxx" parameterType="xxx">
select * from table where column is null;
</select >
3、大于、小于(小于等于)的写法:
//大于的写法
<select id="selectSelective" resultMap="xxx" parameterType="xxx">
select * from table where column > 1;
</select >
//小于的写法
<select id="selectSelective" resultMap="xxx" parameterType="xxx">
select * from table where column < 1;
</select >
//小于等于的写法
<select id="selectSelective" resultMap="xxx" parameterType="xxx">
select * from table where column <= 1;
</select >