I\'ve got a logs table with an ID column in it, and I want to do the following:
Change your variable name in second query, using same variable in both queries can produce unexpected results
select * from
(select id, @rownum := @rownum + 1 as 'row'
from logs, (select @rownum := 0) r order by id) a
join
(select id, @rownum1 := @rownum1 + 1 as 'row1'
from logs, (select @rownum1 := 0) r order by id) b
on a.row = b.row1;