I\'m looking for a way to sequentially number rows in a result set (not a table). In essence, I\'m starting with a query like the following:
SELECT
AFAIK, there's no "standard" way.
MS SQL Server has row_number(), which MySQL has not.
The simplest way to do this in MySQL is
SELECT a.*, @num := @num + 1 b from test a, (SELECT @num := 0) d;
Source: comments in http://www.xaprb.com/blog/2006/12/02/how-to-number-rows-in-mysql/