mysql> select lecture,title,@i:=@i+1 as iterator from opgaver,(select @i:=0) foo where lecture=11 order by `order`; +---------+---------------------+----------+ | lecture | title | iterator | +---------+---------------------+----------+ | 11 | Gruppens opst?en | 1 | | 11 | Favoritemne | 2 | | 11 | Indspilningsstudier | 3 | | 11 | Antal medlemmer | 4 | +---------+---------------------+----------+ 4 rows in set (0.02 sec)