正确的事例:
select * from 表
<where>
<if test="startDate != null and startDate != ''">AND audit_date <![CDATA[>=]]> #{startDate}</if>
<if test="endDate != null and endDate != ''">AND audit_date <![CDATA[<=]]>#{endDate}</if>
</where>
<if test="startDate != null and startDate != ''">AND audit_date <![CDATA[>=]]> #{startDate}</if>
<if test="endDate != null and endDate != ''">AND audit_date <![CDATA[<=]]>#{endDate}</if>
</where>
只选择开始时间,只选择结束时间,同时选择开始时间和结束时间,发现查询的结果都是正确的。