Oracle-like ROWNUM in MySQL

Sometimes in MSSQL, you need to mimic the Oracle ROWNUM functionality.  Here are some tips on ways to compress it into a single line of SQL.Where there it is not possibile to initiate a counter in the previous statement with

SET @rownum:=0;

It is still possible in a single SQL.

SELECT @rownum:=@rownum+1 rownum, t.*FROM (SELECT @rownum:=0) r, mytable t;

archived from Mark Malakanov