Skip to content

Instantly share code, notes, and snippets.

@mAu888
Created February 7, 2012 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mAu888/1759426 to your computer and use it in GitHub Desktop.
Save mAu888/1759426 to your computer and use it in GitHub Desktop.
Rearrange an order column
-- 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