SELECT extracted_ads_id, prop_street_no, prop_street_name
FROM extracted_ads_tbl
WHERE pin-on-off=0
####
INSERT INTO enhanced_ads_tbl
(enhanced_ad_id,extracted_ads_id,pin)
VALUES (NULL,?,?)
####
....snip....
my $query1 = "SELECT field1,field2,field3 FROM table WHERE `flag`=0";
my $sth = $dbh->prepare($query1);
$sth->execute();
# Loop query to build an array
# this pulls each row into an
# array that we can manipulate
while ( ($var1,$var2,$var3) = $sth->fetchrow_array() ) {
# update the flag field to reflect the ad has been ehnanced
my $query2 = "UPDATE table SET `flag`='1' WHERE field1=?";
my $sth2 = $dbh->prepare($query2);
$sth2->execute($var1);
....snip....
}