I don't know if my error is in my SQL or in my PERL, but when I run this script, rows that should be caught, are being left out. About 1,100 rows out of about 11,000 are being missed.
Code:
#!/usr/local/bin/perl -w
use DBI;
#mysql config variables
$user = "me";
$pw = "secret";
$sel = "select `FM Reference`, HouseType.ht_id from hoursworked, HouseType where hoursworked.`FM Reference` = HouseType.design_production_no";
$db_bdb= DBI->connect('dbi:mysql:database=contacts;host=localhost:3306', $user, $pw, { RaiseError => 1, AutoCommit => 1 });
$rows = $db_bdb->selectall_arrayref($sel);
foreach $row(@$rows){
$sql = "UPDATE hoursworked SET ht_id = @$row[1] WHERE `FM Reference` = '@$row[0]';";
print "$sql\n";
}