web analytics

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;