[英]auto delete rows according to a date field using mysql
I have a table with a field end date
. 我有一个字段end date
的表。 I would like that all rows that contain a record in the end date
field get deleted when the date is passed. 我希望在日期过去时删除在end date
字段中包含记录的所有行。
Once I have the right msyql syntax/command, I can make a cron job from it. 一旦有了正确的msyql语法/命令,就可以从中进行cron作业。
Can anyone help me out? 谁能帮我吗? Thanks in advance! 提前致谢!
DELETE FROM table WHERE end_date IS NOT NULL 从表WHERE end_date IS NOT NULL删除
end_date field must be null for those records that should not be deleted. 对于那些不应删除的记录,end_date字段必须为null。
或类似这样的东西:
DELETE FROM db_table WHERE end_date<NOW() AND end_date IS NOT NULL
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.