We have existing table:
| id | name | color | calories |
------------------------------------------
| 1 | apple | red | 20 |
| 2 | orange | orange | 10 |
| 3 | grapes | green | 5 |
| 4 | bananas | yellow | 15 |
| 5 | plum | purple | 25 |
------------------------------------------
Column id
is unique and primary key. I'm facing a problem with edit/update records when, i heed to change for example in row 3 where, id = 3
to id = 5
and row 5 where, id = 5
to id = 3
... Like swap id between rows 3 and 5. Of course there are duplicate, but how to resolve this scenario...
But MySQL logically throws out the error.
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '5' for key 'PRIMARY'
I know it is stupid scenario, but we have a customer who wants it that way. He want to edit/update each existing records.