简体   繁体   中英

Procedure to delete all rows in a column older than 30 days

谁能帮我编写一个过程/函数,从MySQL数据库中所有表中的名为prs_date的列中删除30天以上的行?

看一下DATEDIFF运算符并将其与CURDATE()

DELETE FROM myTable WHERE DATEDIFF(CURDATE(), prs_date) > 30;

该查询可以帮助

DELETE FROM sometable WHERE TO_DAYS(NOW()) - TO_DAYS(prs_date) <= 30;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM