Skip to content

Instantly share code, notes, and snippets.

@matthisamoto
Created July 18, 2012 19:48
Show Gist options
  • Save matthisamoto/3138415 to your computer and use it in GitHub Desktop.
Save matthisamoto/3138415 to your computer and use it in GitHub Desktop.
get rank of item in table MySQL
SET @rownum := 0;
SELECT rank FROM (SELECT @rownum := @rownum + 1 AS rank, id, complete FROM users WHERE complete=1 ORDER BY created_at) as result WHERE id=27;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment