ID order
1 2
2 4
3 5
如何让order大于3的地方,order自动减去1呢?
比如上面的table经过运行sql,变成
ID order
1 2
2 3
3 4
6 个解决方案
#1
update table set order=order-1 where order > 3
#2
select ID, order=(case when order>3 then order-1 else order end) from [yourtable]
#3
select ID, (case when order>3 then order-1 else order end) as order from table
#4
select ID, order=(case when order>3 then order-1 else order end) from tablename
#5
非常感谢!!
#6
update biao1 set order=order-1 where order > 3
#1
update table set order=order-1 where order > 3
#2
select ID, order=(case when order>3 then order-1 else order end) from [yourtable]
#3
select ID, (case when order>3 then order-1 else order end) as order from table
#4
select ID, order=(case when order>3 then order-1 else order end) from tablename
#5
非常感谢!!
#6
update biao1 set order=order-1 where order > 3