I have 2 databases, on different host servers: users & users_addresses
I want to query both databases in 1 single query.
Here's the connections I've set up so far:
$dbh1 = mysql_connect($hostname, $username, $password);
$dbh2 = mysql_connect($hostname, $username, $password, true);
mysql_select_db('users', $dbh1);
mysql_select_db('users_addresses', $dbh2);
But the actual query gets confusing. Below I'm attempting to query both databases in a single query, based on 1 common uid, and I'm getting weirded out by what's the actual approach to it all.
$query = "SELECT tb1.*, tb2.* ";
$query .= "FROM users tb1, users_addresses tb2 ";
$query .= "WHERE tb1.uid = tb2.uid ";
$qeury .= "AND tb1.uid = 5 ";
mysql_query($query);
Naturally this isn't working. Does anyone know if I need to specify a host inside the query itself? or will I need to add $dbh2 anywhere? Not finding much online about different host connections. But I was successful connecting on the same host, different databases.