title: Connecting multiple database and join query across database in php
body: <p>Using php i wants to make a join query across 2 database.</p>
  
  <p>This is my first connection.</p>
  
  <pre><code>$conn = mysql_connect('localhost','root1','pass1'); 
  @mysql_select_db('database1',$conn);
  </code></pre>
  
  <p>This is my second connection.</p>
  
  <pre><code>$conn1 = mysql_connect('localhost','root2','pass2'); 
  @mysql_select_db('database2',$conn1);
  </code></pre>
  
  <p>If i wants to get the data from database1 i am doing following thing.</p>
  
  <pre><code>$sql = 'SELECT * FROM users';
  
  $result = mysql_query($sql, $conn);
  
  print_r(mysql_fetch_array($result));
  </code></pre>
  
  <p>Similarly for second database2</p>
  
  <pre><code>$sql = 'SELECT * FROM orders';
  
  $result = mysql_query($sql, $conn1);
  
  print_r(mysql_fetch_array($result));
  </code></pre>
  
  <p>But i am facing problem when i am making join query as follows</p>
  
  <pre><code>$sql = 'SELECT a.fname AS fname, a.lname AS lname FROM database1.users a JOIN database2.orders b ON b.creator_id = a.id';
  
  $result = mysql_query($sql);//what should be second parameter over here.
  
  print_r(mysql_fetch_array($result));
  </code></pre>