2

I'm trying to get row 5 to 10 when sorting by date but for some reason I always end up with this sql error:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ORDER BY CreatedDate) AS Row, GameID, UserID, Title, Description, CreatedDate F' at line 1

This is the query I'm trying to use:

SELECT ROW_NUMBER() OVER (ORDER BY CreatedDate) AS Row, GameID, UserID, Title, Description, CreatedDate
FROM game
WHERE Row >= 5 AND Row <= 10

Does someone know what I'm exactly doing wrong here? Or even a better way to solve this problem?

Thanks for reading/helping

jarlh
  • 42,561
  • 8
  • 45
  • 63
user4598368
  • 65
  • 1
  • 2
  • 7

1 Answers1

1

There isn't a rownumber() function in MySQL. This is the closest you can get:

SELECT 
    @i:=@i+1 AS rank, 
    t.*
FROM 
    tblname AS t,
    (SELECT @i:=0) AS R
Thanos Markou
  • 2,587
  • 3
  • 25
  • 32