我的数据库表中有sent_date和status列。当前帖子的状态是=已发送/已接收。我只想在5天后自动更改状态=中止。
我的所作所为:
CREATE EVENT reset ON SCHEDULE EVERY 1 day DO
update barter_proposals
set proposal_status="Aborted"
WHERE `sent_date`>=DATE_ADD( CURDATE(), INTERVAL 1 day )
AND proposal_status = "Sent/Received"---------Not worked
CREATE EVENT rot ON SCHEDULE EVERY 1 day DO
update barter_proposals
set proposal_status="Aborted"
WHERE DATE_ADD(sent_date, INTERVAL 1 day )>=NOW()
AND proposal_status = "Sent/Received"---------Not worked
CREATE EVENT rot ON SCHEDULE EVERY 1 day DO
update barter_proposals
set proposal_status="Aborted"
WHERE sent_date=CURDATE()
AND proposal_status = "Sent/Received"-----------Not Worked
任何人都可以告诉我该做什么,以便在5天后自动更新状态。发明可以是任何内容。
如果sent_date是26/03/2018然后是01/04/2018,状态应该自动更新为Aborted。任何人都可以提供逻辑吗?
任何帮助都将受到高度赞赏。
答案 0 :(得分:0)
尝试CURDATE()-5
CREATE EVENT rot ON SCHEDULE EVERY 1 day DO
update barter_proposals
set proposal_status="Aborted"
WHERE sent_date=DATE(CURDATE()-5)
AND proposal_status = "Sent/Received"