For example that I want to select from database 1 and insert the results to database 2. I will use subquery
//db1
$db1_host = "remote.remotehost.com";
$db1_username = "mysqluser1";
$db1_password = "mypassword1"; // encrypted
$db1_name="database1";
$db1_conn = mysql_connect( $db1_host, $db1_username, $db1_password );
//$db1_selected = mysql_select_db($db1_name, $db1_conn);
//get the data from database1
$sql_select_records_from_databse1="SELECT field_1, field_2 FROM database1.table1";
//db2
$db2_host = "localhost";
$db2_username = "mysqluser2";
$db2_password = "mypassword2"; // encrypted
$db2_name="database2";
$db2_conn = mysql_connect( $db2_host, $db2_username, $db2_password );
$db2_selected = mysql_select_db($db2_name, $db2_conn);
$sql_insert_records_to_database2="INSERT INTO table_a (field_a, field_b) $sql_select_records_from_databse1";
Do you mean that I can do something like this? Even 1 database is on local machine, the other database is on remote machine?
Even the user name and password are different for the two databases? (I can set up localhost user name and password the same as the remote host name and password if it will make difference.)
Thanks!