my $sth = $dbh->prepare(" SELECT cols FROM ".$dbh->quote_identifier($tableName)." WHERE col=constant AND col2=constant "); $sth->execute(); while (my $row = $sth->fetchrow_hashref) { ... }