Skip to content

Instantly share code, notes, and snippets.

@gracefullight
Created December 22, 2016 13:41
Show Gist options
  • Select an option

  • Save gracefullight/94bfeaae33efcbf8a7c172769a7984ed to your computer and use it in GitHub Desktop.

Select an option

Save gracefullight/94bfeaae33efcbf8a7c172769a7984ed to your computer and use it in GitHub Desktop.
SELECT SQL_CALC_FOUND_ROWS @RNUM:=@RNUM+1 AS ROWNUM, R.* FROM (
SELECT @RNUM:=0, Q.* FROM (
SELECT * FROM TABLE1
WHERE ID = '1'
ORDER BY REG DESC
) Q
) R
LIMIT 0,10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment