my ($col1,$col2, $col3) = $dbh->selectrow_array("SELECT col1,col2,col3 FROM database where whatever='something' limit 1"); #### $sth->execute(); my $names = $sth->{NAME}; while(my $r = $sth->fetchrow_hashref) { foreach my $name (@$names) { print "$name is $r->{$name}\n"; } }