I am able to find out the duplicate data using this query
SELECT names FROM group GROUP BY names HAVING count(*) > 1
I am able to get the duplicate data.I just need to know how to rename this duplicate data with the name to new
INPUT
+-----------------+
| names |
+-----------------+
| text1 |
| text2 |
| text3 |
| text1 |
| text3 |
| text4 |
+-----------------+
OUTPUT
+-----------------+
| names |
+-----------------+
| text1 |
| text2 |
| text3 |
| text1 new value |->RENAMED
| text3 new value |->RENAMED
| text4 |
+-----------------+
Assuming you have some sort of primary key on the table, like an auto increment id, you can do the following.
To explain, it will find anything with a duplicate, pick up the Maximum ID for anything in that set, and append "copy 1" to the end of it. You may still have some left as duplicates if you had certain names 3 or more times. Just run it again , this time with 'copy 2' instead of 'copy 1'. Keep repeating this process until you get rid of all the duplicaates.
Update. To borrow an idea from @Yahia and use UUID, you can do the following if you want to do it all in one query.
use (corrected as per comment)
this makes all duplicates unique with one execution by concatenating a unique UUID_SHORT... except the one with the smallest ID - it stays untouched...
Try this one -
EDIT:
Full code -