I need to update duplicate rows with different values in same table. my table is
table(id, phoneId(int), deviceId(int), userId(int))
There are some records with same deviceId or phoneId. for example
id phoneId deviceId userId
1 23 3434 1235
2 23 5453 235 <---- same phoneId with 1 record
3 43 5453 2343 <---- same deviceId with 2 record
4 23 3434 6347 <---- same deviceId and phoneID with 1 record
what i need to change is - if phoneId is not unique, set phoneId to userId(from this row). same at deviceId. (if deviceId is not unique, set deviceId to userId)
so the final result should be this
id phoneId deviceId userId
1 23 3434 1235
2 235 5453 235 <---- phoneId changed to userId
3 43 2343 2343 <---- phoneId changed to userId
4 6347 6347 6347 <---- phoneId and deviceId changed to userId