简体   繁体   中英

Update table field values with value-1

I'm having a table of users positions, like position 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 .

eg:

If position 2 user leaves, I need to change positions like 3 to 2 , 4 to 3 , 5 to 4 , etc.

Is there any function in mysql that i can use for this type of update?

这样的事情可能会起作用...

update users set position = position-1 where position > 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM