user864720
user864720

Reputation:

phpmyadmin - delete duplicates

could you please let me know, how should I construct sql query to remove duplicates in my database ?

Please see the structure:

---------------------------------------
| id | search_text | search_text_link |
---------------------------------------
| 1  | qwerty      | qwerty.html      | 
| 2  | qwerty123   | qwerty123.html   | 
| 3  | qwerty456   | qwerty456.html   | 
| 4  | qwerty      | qwerty000.html   | 
---------------------------------------

I want to remove all duplicates by search_text row. Many thanks for any help!

Upvotes: 0

Views: 787

Answers (1)

Marco
Marco

Reputation: 57593

Try this (after taking a backup):

DELETE t1 
FROM your_table t1, your_table t2 
WHERE t1.id > t2.id 
  AND t1.search_text = t2.search_text

Upvotes: 1

Related Questions