Jump to content

Housekeeping cron job leaving just the newest 1 entry per userid


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.