mysql时间加7天减7天

SELECT
  cb.*,
  (
    CASE
      WHEN NOW()<cb.continue_time_start 
      THEN '2'
      WHEN NOW()>cb.continue_time_start
      AND  NOW()<cb.continue_time_end
      THEN '3'
      WHEN NOW() >cb.continue_time_end
      THEN '1'
    END
  ) AS resubmit_status,
  tc.head_pic,
  NOW() AS now_date
FROM
  (SELECT
    *
  FROM
    (SELECT
      *
    FROM
      `py_class_base`
    WHERE id IN
      (SELECT
        purpose_class_id
      FROM
        `py_class_resubmit`
      WHERE DATE_SUB(start_time, INTERVAL 7 DAY) < NOW() #start_time开始时间往前推7天
        AND NOW() < DATE_ADD(end_time, INTERVAL 7 DAY)#end_time 结束时间往后推7天
        AND source_class_id IN
        (SELECT
          class_id
        FROM
          py_order_class
        WHERE user_id = 1106
          AND refund_status = 0))
      AND class_status = 1) pcb) cb
  LEFT JOIN py_teacher tc
    ON cb.teacher_id = tc.id
ORDER BY resubmit_status
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值