0

I have this table below in mySQL with thousands of rows. If you notice 1, 2, 3 token are the same but the 3rd token has a different IP.

token                                  ip
4aa1813449465a6ec1fc82e0ef09e2b1       2.17.58.126
4aa1813449465a6ec1fc82e0ef09e2b1       2.17.58.126
4aa1813449465a6ec1fc82e0ef09e2b1       94.71.213.235
d41d8cd98f00b204e9800998ecf8427e       63.24.23.129

My question is how can I end up with removing all duplicates rows ( token + ip ) ending with this

token                                  ip
4aa1813449465a6ec1fc82e0ef09e2b1       2.17.58.126
4aa1813449465a6ec1fc82e0ef09e2b1       94.71.213.235
d41d8cd98f00b204e9800998ecf8427e       63.24.23.129
1
  • Do you want to select or delete? Commented Aug 30, 2014 at 14:00

1 Answer 1

1
SELECT DISTINCT * FROM <table>;

To create a new cleaned up table:

SELECT DISTINCT * INTO <newtable> FROM <table>;

To clean up the table inline you would need to have a unique primary key, you cannot 'deduplicate' completely identical rows since you cannot target the individual duplicates.

Sign up to request clarification or add additional context in comments.

2 Comments

Will this work if instead of the * write token, ip ?
If those are the only 2 fields it's identical - * just means 'all available fields'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.