<select id="selectSelective" parameterType="com.xx.vo.Jscg" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from jscg
where 1=1
<if test="id!=null and id!='' ">
AND id = #{id,jdbcType=INTEGER}
</if>
<!-- 标题模糊查询 -->
<if test="jsCgname!=null and jsCgname!='' ">
AND js_gname LIKE CONCAT('%',#{jsCgname},'%')
</if>
<!-- 时间查询:字符串格式或时间格式 -->
<if test="startTime!=null and startTime!='' ">
<![CDATA[ and js_chkdate >= #{startTime} ]]>
</if>
<if test="endTime!=null and endTime!='' ">
<![CDATA[ and js_chkdate <= #{endTime} ]]>
</if>
</select>
比较两个数字大小
<select id="selectMaxPicState" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from carousel where <![CDATA[ pic_state > #{picState,jdbcType=INTEGER} ]]> order by pic_state desc
</select>