I am useing the following code to Do two joins. Basically putting duplicate records into one table and new records into another table...
I have tried both mysql_num_rows() and mysql_affected_rows() to try to get a count of the number of records inserted into the two tables.. neither is working.. get not valid mysql resource error...
How can I get a count of the records inserted?
//Move good records to the `good` table
//csv is not empty and work insert matched csv so check for duplicates
// insert into table2 (col1, col2, col3, col4) (select col1, col2, col3, col4 form table1 where col1 in (1,2,3,4));
$sql4 = "INSERT IGNORE INTO good (telephone)(SELECT upload_file.telephone FROM upload_file LEFT JOIN mainfile ON upload_file.telephone=mainfile.telephone WHERE mainfile.telephone is null)";
$r4 = mysql_query($sql4, $deduper)or die("ERROR: ".mysql_error());
$c2 = mysql_affected_rows($r4);
echo "<br>good records:". $c2;
//Move bad records to the `bad` table
//csv is not empty and work insert matched csv so check for duplicates
// insert into table2 (col1, col2, col3, col4) (select col1, col2, col3, col4 form table1 where col1 in (1,2,3,4));
$sql5 = "INSERT IGNORE INTO bad (telephone)(SELECT upload_file.telephone FROM upload_file,mainfile where upload_file.telephone=mainfile.telephone)";
$r5 = mysql_query($sql5, $deduper)or die("ERROR: ".mysql_error());
$c3 = mysql_num_rows($r5);
echo "<br>Duplicate records:". $c3;