update table set ID = 10 where ID = 5" #### my $update_sth = $dbh->prepare( "update table set ID=? where ID=5 and Name=?"); my $select_sth = $dbh->prepare( "select Name from table where ID=5" ); my $new_ID = 10; $select->execute; while ( my $row = $select->fetchrow_arrayref ) { my $name = $$row[0]; $update_sth->execute( $new_ID++, $name ); }