In MSSQL, we have row_number, and in MySQL, we have limit

Sometimes, the task is to find the record before and after a certain record. When the ordering is complex, it seems not easy for MySQL to do this, so row_number can be useful here.

But MySQL does not support row_number (when this entry is written at MySQL 5.1.50)
Here is one widely used solution:
set @row_number=0;select(@row_number:[email protected]_number+1)as`row_number`from...
(For php using mysql_query, the above should be put into 2 mysql_query functions)