my $sth = $dbh->prepare('SELECT * FROM [Production Words]'); $sth->execute; # finish the rest of this line after you design the new table my $new_sth = $dbh->prepare('INSERT INTO new_table ...'); my %hash; while (my $row = $sth->fetchrow_hashref) { #### my ($str,$num) = $row->{ID} =~ /(\D+)(\d+)/; my $new_id = lc($str) . int($num); #### unless ($hash{$new_id}++) { # INSERT $row into the new table $new_sth->execute( ... ); } else { # possibly fetch existing row and check to see # if this redundant old row has better data } }