$sql = "select cols from $tableName where col=constant and col2 =constant"; my $sth = $db->prepare($sql); $sth->execute or die "SQL Error: $DBI::errstr\n"; while ($row = $sth->fetchrow_hashref) { #analyse each row