当前位置:Gxlcms > 数据库问题 > mysql查询,根据时间查询:几天前、几天内的数据

mysql查询,根据时间查询:几天前、几天内的数据

时间:2021-07-01 10:21:17 帮助过:32人阅读

!-- 更新5天前的订单 审核中-6 改成 审核失败-81 create_time <= DATE_SUB(now(), INTERVAL 5 DAY) 5天前,精确到秒 --> <update id="updateStatsByTime" parameterType="java.lang.Integer" > UPDATE user_partya_order SET stat = 81 WHERE id IN(select id from ( SELECT id FROM user_partya_order WHERE loan_id = #{id} AND create_time &lt;= DATE_SUB(now(), INTERVAL 5 DAY) and stat = 6 ) AS a ) </update>

 

示例2:

    <!--
    查询用户5天内的订单
    create_time > DATE_SUB(now(), INTERVAL 5 DAY) 5天内,精确到秒
    -->
   <select id="findRemoveOrder" parameterType="java.util.Map"  resultMap="mapUserPartyaOrderDTO">
         SELECT id,create_time,order_no,loan_id, stat,user_id,borrower_id,loan_app_id,bank_no,is_repeat_loan
                FROM user_partya_order
                WHERE 1=1 AND stat=6
                AND create_time &gt; DATE_SUB(now(), INTERVAL 5 DAY)
                AND loan_id =#{loanId}
                AND user_id=#{userId} ORDER BY create_time DESC  LIMIT 1
   </select>

 

核心标红!

 

mysql查询,根据时间查询:几天前、几天内的数据

标签:sql查询   apu   result   sql函数   更新   mysql   color   art   style   

人气教程排行