Skip to content

Instantly share code, notes, and snippets.

@glafarge
Created August 22, 2016 13:31
Show Gist options
  • Save glafarge/17fc33f0ce1ae5765f3a8b7812389558 to your computer and use it in GitHub Desktop.
Save glafarge/17fc33f0ce1ae5765f3a8b7812389558 to your computer and use it in GitHub Desktop.
Reincrement field of a MySQL table
SET @pos := 0;
UPDATE table SET position = ( SELECT @pos := @pos + 1 ) ORDER BY id ASC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment