How to get the row number or rank of row in mysql?

It should be done as follows:

SELECT @x:= @x + 1 AS rank, title FROM t1 JOIN ( SELECT @x:= 0 )X ORDER BY weight

Leave a Reply