SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast mymamasaid's Avatar
    Join Date
    Sep 2000
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help! Auto delete table rows script

    I need a script that will automatically delete all mysql table rows that are 90 days old (one of the columns in the table is a timestamp -- 14, I think -- yyyy-mm-dd hh:mm:ss). Is there a way I can get phpmyadmin to perform this? Or will I need a php snippet to do this (and cron, I suppose, yes?).

    tia!
    Kristine
    silly boy, web design is for girls
    MyMamaSaid.com :: MomsPDA.com :: iDotDesigns.com

  2. #2
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The query probably works like this (no guarantees)

    Code:
    DELETE FROM yourtable 
    WHERE datecolumn < DATE_ADD(NOW(), interval -90 day);
    And probably a cron job is the best solution.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •