SELECT @rank :=@rank + 1 AS rownum, a.* FROM ( SELECT * FROM table_name r ) a, (SELECT @rank := 0) b