Skip to content

Instantly share code, notes, and snippets.

@razbakov
Last active December 18, 2015 10:29
Show Gist options
  • Save razbakov/5768511 to your computer and use it in GitHub Desktop.
Save razbakov/5768511 to your computer and use it in GitHub Desktop.
SELECT mod(num,PAGE_SIZE) as row, ceil(num/PAGE_SIZE) as page
FROM (SELECT *, @rownum:=@rownum + 1 AS num FROM users, (SELECT @rownum:=0) r ORDER BY username) d
WHERE d.userid=141414
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment