php - Add Number for duplicate entry in sql -
i have table :-
id name email username 1 johen mak jojo@yahoo.com johen_mak 2 johen mak jojo@gmail.com jojo 3 gawil gorgy jojo@homail.com gawil_gorgy 4 johen mak jojo@yamail.com jojo 5 johen mikik jojo@yamail.com jojo
in table in database entry in same username
, need add _1 .... end username
i need update above table this:-
id name email username 1 johen mak jojo@yahoo.com johen_mak 2 johen mak jojo@gmail.com jojo 3 gawil gorgy jojo@homail.com gawil_gorgy 4 johen mak jojo@yamail.com jojo_1 5 johen mikik jojo@yamail.com jojo_2
how can that
i know solution don't answer problem have perhaps you:
update tablename t join tablename t2 on t1.id<t2.id , t1.name = t2.name set t2.name=concat(t2.name,'_',t2.id)
this add _id duplicates names after first one
Comments
Post a Comment