mysql: rownum functionality

Here are some examples how to use “rownum” functionality (similar to Oracle) in mysql


update mytable
set col1 = 'somevalue'
order by col2
limit 300

rownum analog:


select @rownum:=@rownum+1 rownum, mytable.*
from (select @rownum:=0) r, mytable;