mysql - updating a column value in sql that start from last row -



mysql - updating a column value in sql that start from last row -

i have table having column name id(primary key).

in have values 1 152.

now want update table id ranging 109 152 incremented 1.

when run sql

update category set id=(id+1) id<152 , id>108

it give error because when update id=109 110 found duplicate of 110 in next row.

so how can that.

can start updating lastly row 152 , stop on 108.

i guessing using mysql. if so, can using order by.

update category set id = id + 1 id > 108 , id < 152 order id desc;

assuming ids positive, next should work in database (assuming column not declared "unsigned"):

update category set id = -(id + 1) id > 108 , id < 152; update category set id = -id id < 0;

mysql sql sql-server

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -