my $sql_select = "select * from $tableName"; $sth->execute or die $sth->errstr; $sql_delete = "delete from $tableName where LiftChr=? and LiftPos=?"; my $sth1 = $db->prepare($sql_delete); while ($snp = $sth->fetchrow_hashref) { $sth1->execute($snp->{'LiftChr'}, $snp->{'LiftPos'}); }