SQL query to delete all rows older than 30 days

Updated at 21-Oct-2021, By samar

SQL query to delete all rows older than 30 days

We’ll attempt to use programming in this lesson to solve the "SQL query to delete all rows older than 30 days" puzzle.

You can delete all rows from table which are older than 30 days. You have to use where created_at < now() - interval 30 DAY to get the records which are older than the 30 days from current date and Delete statement will delete It.
  • Delete 30 days older records from table using SQL query

    //Syntax:
    Delete from <table> where <date_column> < now() - interval 30 DAY
    
    //SQL Query Example:
    Delete from Users where created_at < now() - interval 30 DAY
    

    This SQL query helps you to delete the 30 days older records from today's date from a table.

Back to code snippet queries related sql