http://www.perlmonks.org?node_id=972840

romy_mathew has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Can anybody suggest how to display a row number in mysql query. I am able to get this done in mysql query by

select @rownum:=@rownum+1 AS rank, p.* from player p, (SELECT @rownum:=0) r order by score desc limit 10

But when I use this in $sth = $dbh->prepare("Select @rownum:=@rownum+1 ‘rank’, p.* from player p, (SELECT @rownum:=0) r order by score desc limit 10");

I get errors and the statement is not getting executed. ANy Suggestion ...?