[英]Update table field values with value-1
I'm having a table of users positions, like position 1,2,3,4,5
. 我有一张用户位置表,例如位置
1,2,3,4,5
。 Now when any user leaves, I will delete that row and I need to update other users position with -1
. 现在,当任何用户离开时,我将删除该行,并且需要使用
-1
更新其他用户的位置。
eg: 例如:
If position 2 user leaves, I need to change positions like 3 to 2
, 4 to 3
, 5 to 4
, etc. 如果位置2的用户离开,我需要将位置更改为
3 to 2
4 to 3
5 to 4
等。
Is there any function in mysql that i can use for this type of update? mysql中有没有我可以用于这种类型的更新的功能?
这样的事情可能会起作用...
update users set position = position-1 where position > 2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.