http://qs321.pair.com?node_id=518498


in reply to Re^2: Perl or SQL ?
in thread Perl or SQL ?

$sth->fetch returns an array reference, and $sth->fetchrow returns a list. Each item in the array or list is a column in the SELECT statement. So:

$sth = $dbh->prepare("select a, b, c from foo"); $sth->execute; while($row = $sth->fetch) { # $row->[0] is column 'a' # $row->[1] is column 'b', # etc... }
and
while(($one, $two, $three) = $sth->fetchrow_array) { # $one, $two and $three are columns a, b and c }
Michael