赞
踩
推荐方式一和方式和,因为方式三使用了函数DATE_FORMAT,这样导致时间p.create_time索引失效;
其中between ..and ...相当于 [ >= <= ]的使用范围
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and p.create_time >=#{startTime} AND p.create_time <=#{endTime}
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
- and p.create_time between #{startTime} and #{endTime}
- </if>
- <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
-
- <![CDATA[ and DATE_FORMAT(p.create_time, '%Y-%m-%d %H:%T:%s') >
- DATE_FORMAT(#{startTime} , '%Y-%m-%d %H:%T:%s') ]]>
-
- <![CDATA[ and DATE_FORMAT(p.create_time, '%Y-%m-%d %H:%T:%s') <=
- DATE_FORMAT(#{endTime} , '%Y-%m-%d %H:%T:%s') ]]>
- </if>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。