标签:sql查询 apu result sql函数 更新 mysql color art style
示例中 mysql字段类型为 datetime
使用到mysql函数 DATE_SUB() 和 now()
示例1:
<!-- 更新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 <= 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 > DATE_SUB(now(), INTERVAL 5 DAY) AND loan_id =#{loanId} AND user_id=#{userId} ORDER BY create_time DESC LIMIT 1 </select>
核心标红!
标签:sql查询 apu result sql函数 更新 mysql color art style
原文地址:https://www.cnblogs.com/007sx/p/12620105.html