$where_clause = 'where id in ('.join(",",("?") x @id).')'; $sql .= $where_clause; my $sth = $dbh->prepare($sql); $sth->execute(@id); #### $sql .= 'where id = ?'; my $sth = $dbh->prepare($sql); for my $id (@id) { $sth->execute($id); ... }