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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -