Reputation:
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
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