Search code examples
mysqlsql-deletedelete-record

How to delete all records created today?


I am dealing with a very big database ~ 6 Million records. I've added ~30,000 bad records today. How can I delete all of the records created today in MySQL?


Solution

  • It seems created_at is a datetime. Try:

    delete from table
    where date(created_at) = curdate()
    

    Of course, run a select * prior to run this query and make sure the data you're going to delete is the one you really want to delete.