But what if you have a group by in the select statement? the counting will be off.
For such cases, the only solution I found is nesting select:
SELECT (@cnt := @cnt + 1) AS rowNumber, t.*
from
(select
t.rowID
FROM myTable
WHERE CategoryID = 1
ORDER BY rowID) t
CROSS JOIN (SELECT @cnt := 0) AS dummy