工作第一周。多条件以及时间语句的查询

来源:互联网 发布:屏幕闪光灯软件 编辑:程序博客网 时间:2024/06/03 18:40
<where>  <if test="null !=city and '' !=city ">    AND s.city = #{city}  </if>  <if test="null !=status and '' !=status">    AND sr.status = #{status}  </if>  <if test="null !=beandName and '' !=beandName">    AND db.beandName = #{beandName}  </if>  <!--查询某个时间段 -->  <if test="null !=startTime and null!= endTime">    AND sr.createTime &gt;= #{startDate} and sr.createTime &lt;= #{endDate}  </if>  <!-- 近七天的 -->  <if test="null != sevDays and sevDays != '' ">    AND DATE_SUB(NOW(), INTERVAL 7 DAY) &lt;= sr.createTime  </if>  <!-- 今天 -->  <if test="null != today and today != '' ">    AND DATE_FORMAT(sr.createTime,'%Y-%m-%d')= DATE_FORMAT(NOW(),'%Y-%m-%d')  </if></where>
原创粉丝点击