Delete all rows with timestamp older than x days

后端 未结 2 599
醉酒成梦
醉酒成梦 2020-12-02 13:09

I want to delete all the rows with timestamp older than 180 days from a specific table in my database.

I\'ve tried the this:

DELETE FROM on_search WH         


        
相关标签:
2条回答
  • 2020-12-02 13:39
    DELETE FROM on_search 
    WHERE search_date < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 180 DAY))
    
    0 讨论(0)
  • 2020-12-02 13:45
    DELETE FROM on_search WHERE search_date < NOW() - INTERVAL N DAY
    

    Replace N with your day count

    0 讨论(0)
提交回复
热议问题