Jump to content

Recommended Posts

Hello all. I have a PHP script that is run every 5 minutes by cron, goes into a flash game, and grabs all of the users that are on a few certain servers and inputs their name, user ID, and some other data that isn't relevant to what I'm wondering about into a table. Currently, whenever the same user is found it just makes a new row for the user, and whenever the user is looked up from the web interface for this table, it uses the newest data. This obviously isn't very efficient, as it usually makes about one thousand rows whenever it runs the script. What I'm looking for is a way to look for duplicates of a username, then delete all of the duplicate rows with that username in it EXCEPT for the newest one. This would preferably be run by a cron job. Now, I'm not very savvy with MySQL so I don't know how to do this. If anyone has any guidance on how I can do this, please reply! :)

 

Thanks,

 

Andy

 

PS: my mysql server version is: 5.0.51a

Link to comment
https://forums.phpfreaks.com/topic/137946-removing-duplicate-rows/
Share on other sites

That really depends.  Can the same username be used on multiple servers, or is the username unique?

 

It seems like you're saying it's unique across the servers though.  You could have it do a:

INSERT ... ON DUPLICATE KEY UPDATE

 

It's kinda hard to tell without seeing your structures and knowing what data you are pulling.

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.