」工欲善其事,必先利其器。「—孔子《論語.錄靈公》
首頁 > 程式設計 > 如何根據日期比較自動刪除mySQL行?

如何根據日期比較自動刪除mySQL行?

發佈於2025-03-23
瀏覽:805

How to Automate Deleting MySQL Rows Based on Date Comparison? 
基於日期比較

mysql查詢:

php腳本將執行以下mysql查詢:此查詢從指定表(“ your_table_name”)中刪除和刪除行,其中“ date”值比當前日期早。

創建一個包含此腳本的php文件,並將其保存為“ Cronjobcommand.php”。

替換為“ your_db_connection”,用與您的mysql database。 Setup:

In your control panel (e.g., cPanel), set up a cron job that executes "cronjobcommand.php" at the desired time, such as midnight.

This automated process will periodically clear out outdated rows from your database, ensuring they meet the date-based criteria you have specified.

最新教學 更多>

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3