Skip to content

Instantly share code, notes, and snippets.

@glafarge
Created June 12, 2018 14:12
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 glafarge/ac95cf7bad6c9459a272925560a192c5 to your computer and use it in GitHub Desktop.
Save glafarge/ac95cf7bad6c9459a272925560a192c5 to your computer and use it in GitHub Desktop.
[MySQL] Increment a col with a counter at once
SELECT @i:=0;
UPDATE contacts SET position = @i:=@i+1 WHERE location_id=1 ORDER BY id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment