Sashi Kant Sashi Kant - 1 year ago 81
SQL Question

Is there a way to get the row number in Mysql like the rownum in oracle

Is there a way to get the row number in Mysql like the rownum in oracle, If not then is there any indirect way of doing it?
please suggest.

Answer Source

Until MySQL finally supports modern SQL, the only way to get something similar is this:

SELECT @rownum:=@rownum + 1 as row_number, 
       t.*
FROM ( 
   < your original query goes here >
) t,
(SELECT @rownum := 0) r