How to make execution update reverse query mysql by id? -


i have 5 rows id: 1,2,3,4,5.

then made query try change id to: 2,3,4,5,6

update table set `id` = `id` + 1  

then get:

duplicate entry '2' key 'primary'.

i understand query executed id 1 first , cause primary 2 existed.

so question how make query has been executed id 5 1.

created table num_sample numbers 1 100. defined primary key on column num. , wrote update

update num_sample set num = num + 1 order num desc limit 100; 

worked absolutely fine in mysql.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -