title: Inner Join query on 2 different databases - Mysql
body: <p>We have 2 different databases that I'm trying query against each other with an inner join.</p>
  
  <p>When I run the query from phpmyadmin, the query works perfectly.  However, when I attempt to put the query into a php page, I cannot get the line to work.  I assume I'm missing something in the mysql_select_db line where I reference the host/db/user/pass for the first database.</p>
  
  <p>What am I missing here to get this query to function on the page?  Again, I'm confident the actual query works since it does run in phpmyadmin.</p>
  
  <p>Thanks in advance as always.</p>
  
  <p>Here's the code I'm working with....</p>
  
  <pre><code>$hostname_db = "123.456.78.910";
  $database_db = "votes_db";
  $username_db = "votes_dbuser";
  $password_db = "password123";
  $db = mysql_connect($hostname_db, $username_db, $password_db, true) or trigger_error(mysql_error(),E_USER_ERROR); 
  
  $hostname_db2 = "123.456.78.910";
  $database_db2 = "survey_db";
  $username_db2 = "survey_dbuser";
  $password_db2 = "password456";
  $db2 = mysql_connect($hostname_db2, $username_db2, $password_db2, true); 
  
  // trying to make this work, query ok in phpmyadmin, but not on the php page
  mysql_select_db($database_db, $db);
  $query_testdb3 = sprintf("SELECT votes_db.vote_table.vote_survey_id
  FROM votes_db.vote_table 
  inner join survey_db.survey_table 
  ON votes_db.vote_table.vote_survey_id = survey_db.survey_table.survey_id
  WHERE votes_db.vote_table.vote_survey_id = 1457 ");
  $testdb3 = mysql_query($query_testdb3, $db) or die(mysql_error());
  $row_testdb3 = mysql_fetch_assoc($testdb3);
  $totalRows_testdb3 = mysql_num_rows($testdb3);
  </code></pre>