Jump to content

php/mysql delete oldest entries


acctman

Recommended Posts

Hi I need help with a query that will cycle through the 'com_for' (userid) field and then only keep the latest 200 comments and delete everything after. Example: So if 'com_for' userid 39 has 250 comments then delete the oldest 50 comments. The com_time field holds the time in this format 1133173361

 

table: rate_picture_comments

fields: com_id , com_for , com_comment , com_time 

 

This has been tried with sql only, (I posted in the Mysql section) but mysql wasn't able to handle multiple selects and deleting kept getting a unknown table error and after some researching online it was suggestion in a case like this its best to off load the process to a scripting language like php.

Link to comment
https://forums.phpfreaks.com/topic/149127-phpmysql-delete-oldest-entries/
Share on other sites

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.