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
mysql时间加7天减7天
最新推荐文章于 2024-09-23 00:05:42 发布