Jump to content

Housekeeping cron job leaving just the newest 1 entry per userid


hugeness

Recommended Posts

hello

 

i have a frightening mash up of a database for users.. due to my inability and due to having to run on a Joomla CMS (makes simple php tricky) because of this, i have one form that inserts new records rather than updating existing ones..

the only way i can see to work around this is to run a regular housekeeping cron job on the table to delete  any record where a user has more than one record, by whichever is oldest (the table is timestamped)

 

so far i have something like

 

DELETE * FROM tablename

 

ORDER BY timestamp ASC

 

LIMIT 5;

 

this will delete the previous 5 records.. but thats not neat enough for the table, how do i do a count then delete all but the newest one?

 

thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.