karimali831 Posted March 21, 2012 Share Posted March 21, 2012 Hi all, I have mistakenly inserted duplicated rows and will take forever removing them manually so hoping someone can help me with the SQL to remove duplicated results. You can see the image where the duplicated row begins and so on. The rows userID, clanID and cupID shouldn't have a duplicate. I have fixed this in my script just need to get rid of the duplicates and obviously only having 1 one of the rows. Thanks to anyone Quote Link to comment Share on other sites More sharing options...
floridaflatlander Posted March 21, 2012 Share Posted March 21, 2012 You'r deleting it from phpmyadmin? I think this will do it if you put it in your sql of phpmyadmin fot that table DELETE FROM table_name WHERE id != 16430; if 16430 is the record you want to keep OR DELETE FROM table_name WHERE id != 16430 And cupID = 45; for a little insurance and if you want to get rid of only the 45's Quote Link to comment Share on other sites More sharing options...
smerny Posted March 21, 2012 Share Posted March 21, 2012 hope you didnt do that ^ you'll lose much more than you are hoping to florida, he wants to remove any duplicate rows that cup, clan, and userIDs are all the same Quote Link to comment Share on other sites More sharing options...
smerny Posted March 21, 2012 Share Posted March 21, 2012 i'd back it up first to be safe, but thats just me.. i'd try something like this DELETE from table USING table, table as t WHERE (table.ID>t.ID) AND (table.cupID=t.cupID) AND (table.clanID=t.clanID) AND (table.userID=t.userID) Quote Link to comment Share on other sites More sharing options...
karimali831 Posted March 22, 2012 Author Share Posted March 22, 2012 perfect exackly what I wanted, amazing thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.