Is it possible to find the position of a row in a mysql table?
For example, if we had the mysql query
SELECT * FROM `table` WHERE `Date` > X ORDER BY `Date` DESC
This will select all the rows created after X and arrange them with respect to the date they were created in. Now If I know one of these rows ID, could this query code be modified so that I know what position it is at in this query.
I mean say that the query gives 5 rows and the row which I know its ID is one of them, Is it possible to check what position it has in the query. I mean, is it 1st, 2nd, ..., 5th.
I hope I explained my problem clearly.
Using Blizz suggestion I found that
SET @I=0; SELECT @I:=@I+1 AS `I`, `ID`, `From`, `Action`, `To`, `Value`, `Date` FROM `papers` WHERE `Action` = 'Review' GROUP BY `ID` ORDER BY `Date` DESC
Does what I want however it only works in localhost/phpmyadmin and when I run it in localhost/mysite an error comes up saying
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 'SELECT @I:=@rank+1 AS
rank
,ID
,From
,Action
,To
,Value
,Date
FROM `' at line 1
Does anyone know why this happens?