title: How to connect multiple database,servers in mysql and query from both tables of each other?
body: <p>I am looking forward to connect two different database from different servers. Also, i would want to run a query that fetches data from both the database into a single result. Am doing this in PHP script with mysql. here is how am looking forward to do it [ without success :) ]</p>
  
  <pre><code>$dbh1 = mysql_connect('server1', 'uname', 'pwd')or die("Unable to connect to MySQL1"); 
  $dbh2 = mysql_connect('server2', 'uname', 'pwd') or die("Unable to connect to MySQL2");
  
  mysql_select_db('db1', $dbh1);
  mysql_select_db('db2', $dbh2); //both will have same table name though
  
  $qry = mysql_query("select * from db1.table1 where db1.table1.id='100' and db1.table1.id=db2.table1.id",$dbh1) or die(mysql_error());
  
  $row= mysql_fetch_array($qry);
  
  echo $row[2];
  </code></pre>
  
  <p>Am not getting any result or either error. Any help is appreciated, tnx.</p>