<selectid="GetTotal"resultType="long">
select count(*) from user
<where><!--and 如果是跟在where后面,框架会自动省略--><iftest="name != null and name.trim() != ''">
and name like #{name}
</if><iftest="gender != null">
and gender = #{gender}
</if><iftest="beginDate != null and beginDate.trim() != ''">
and birthday >= STR_TO_DATE(#{beginDate},'%Y-%m-%d')
</if><iftest="endDate != null and endDate.trim() != ''">
and birthday <= STR_TO_DATE(#{endDate},'%Y-%m-%d')
</if><!--
xml语法:
<![CDATA[
and endDate <= #{endDate}
]]
--></where></select>