Created
June 12, 2018 14:12
-
-
Save glafarge/ac95cf7bad6c9459a272925560a192c5 to your computer and use it in GitHub Desktop.
[MySQL] Increment a col with a counter at once
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
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