Last active
March 22, 2017 15:38
-
-
Save gadiener/9d00d205b02b013d17b3817417faa3f6 to your computer and use it in GitHub Desktop.
Add row number to MySql query
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 * FROM | |
( | |
SELECT | |
@i:=@i+1 AS rownum, | |
subq.* | |
FROM | |
( | |
SELECT id,date FROM articles | |
) subq, | |
(SELECT @i:=0) r | |
ORDER BY date ASC | |
) _tmp | |
WHERE rownum > 3 | |
LIMIT 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment