I have about 1000 rows, and want to increment all of the rows' ID number by 1. I was thinking something like this might work
UPDATE table
SET id = id+1
I tried in phpMyAdmin, but got this: Duplicate entry '2' for key 'PRIMARY'
This makes perfect sense, but how can I get around it?
Isn't it much easier to order it backwards?
update table set id = id +1 order by id desc
this works for me...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With