in reply to Display row number perl DBI
Always use strict; use warnings; at the beginning of your perl code. It catches common mistakes, including the one you are making.
The problem is that Perl replaces variable names in double-quoted strings by their value (we call that "interpolation"), and @rownum happens to look like a variable name in Perl. So use single-quote strings instead:
$sth = $dbh->prepare('Select @rownum:=@rownum+1 rank, p.* from player +p, (SELECT @rownum:=0) r order by score desc limit 10');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Display row number perl DBI
by romy_mathew (Beadle) on May 28, 2012 at 17:50 UTC | |
by moritz (Cardinal) on May 28, 2012 at 18:13 UTC | |
by vinian (Beadle) on May 29, 2012 at 08:45 UTC |