Hi, I’ve got 2 tables in MySQL, changelist and fed. I’m going through the changelist table and seeing if the phonenumber is found in the fed table, and if it is deleteing it. I’m kinda new to php+MySQL, and was wondering if there was another way to do this to maybe speed up the process?
[code=php]
//compare dnc.changelist to dnc.fed, removing D’s first, then adding A’s
//grab the phone numbers from dnc.changelist
$sQuery = ‘SELECT fullphone FROM `dnc`.`changelist` WHERE `changetype`=’D”;
$result = mysql_query($sQuery);
if (!$result) {
die(‘Query failed: ‘ . mysql_error());
}
//fetch rows in reverse order
for ($i = mysql_num_rows($result) – 1; $i >= 0; $i–) {
if (!mysql_data_seek($result, $i)) {
echo “Cannot seek to row $i: ” . mysql_error() . “n”;
continue;
}
if (!($row = mysql_fetch_assoc($result))) {
continue;
}
//searching through fed file
//————————-
$query = ‘SELECT `fullphone` from `dnc`.`fed` WHERE `fullphone`= ‘.
$row[‘fullphone’];
$res = mysql_query($query);
$temp_res = mysql_fetch_assoc($res);
if(!empty($temp_res)){
$qQuery = ‘DELETE FROM `dnc`.fed` ‘.
‘WHERE `fullphone`=’.$row[‘fullphone’].”;
mysql_query($qQuery) or die(“Failed while deleting D type record”);
$_SESSION[‘deleted’] = $_SESSION[‘deleted’]+1;
}
}
then I go through again and start adding the ones that have an A in the changetype field in dnc.changelist, anyone have a different way of doing this? or maybe I should look more into the sql side of the code for faster results?