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

php - How to register a post type and taxonomy in WordPress and display in a page/single post -

database - How many Observations in SAS Sample Data Output -

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