Querying across two databases on the same server,
my SELECT Query works, my UPDATE query fails.
Is it not possible to simply SET table1.all_fields = table2.all_fields WHERE condition --
without specifying each field??
<?php
define ('DB_USER', 'admin');
define ('DB_PASSWORD', 'password');
define ('DB_HOST', 'localhost');
define ('DB_NAME1', 'crm2');
define ('DB_NAME2', 'crm');
$dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)or die('Unable to Conntect to Server' . mysql_error());
/////// SELECT Query works /////////////////
$compare_emails = " SELECT *
FROM crm.emails, crm2.emails
WHERE crm2.emails.id='66ed0ee7-8ca8-c215-1b3d-469e55bc6782'
AND crm.emails.id = crm2.emails.id
AND crm.emails.deleted !='1'
";
$result = @mysql_query ($compare_emails)or die ("Query failed - COMPARE EMAILS " . mysql_error()); // Run the query.
$numrows=mysql_num_rows($result);
while ($row = mysql_fetch_assoc($result)) {
$name =$row['name'];
}
echo $name ."<br>";
echo 'numrows = ' .$numrows."<br>";
// If we have no results, die
if ($numrows != 0){
/////// UPDATE query DOESN'T WORK !!! /////////////////
// Make the query.
$query10 = "UPDATE crm.emails, crm2.emails
SET crm.emails = crm2.emails
";
$result = @mysql_query ($query10)or die ("Query failed - EMAILS " . mysql_error()); // Run the query.
}
exit(); // Quit the script.
mysql_close(); // Close the database connection.
// End of the main Submit conditional.
?>