Created
February 7, 2012 12:18
-
-
Save mAu888/1759426 to your computer and use it in GitHub Desktop.
Rearrange an order column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Rearrange a sort column on a table with one UPDATE clause, e.g. after multiple items have been deleted | |
SET @sort_counter = 0; | |
UPDATE table SET sort_column = (@sort_counter := @sort_counter + 1) ORDER BY sort_column ASC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment