If all else fails, just save your data from one db in variables, then use those 
vars in your 
SQL query with the other db.

In other words, something more like:

$Inventory_branch_code = $result_of_1st_query;

$sql = "SELECT tac.casemain.CaseID, tac.casemain.BranchID from tac.casemain 
WHERE 
tac.casemain.BranchID = '$Inventory_branch_code'";

Hope this helps, 

Ken Krauss
http://www.kcwebdev.com



--- In [email protected], Khan <[EMAIL PROTECTED]> wrote:
>
> 
>     .
> 
>    Dear Friends!
> 
> I have got two databases on two different PCs, A & B. 
> 
> When i was developing the software, i locally copied the tables from PC B to 
> PC A.
> 
> Since the tables in PC-B are updating regularly so now i need to call these 
> tables from 
PC-B to PC-A, without locally copying them.
> 
> 
> The database on PC-A is named as "tac"
> The database on PC-B is named as "Inventory"
> 
> and using both databases i am trying to execute an INNER JOIN SELECT query, 
> like the 
same way i used to execute when i had the local copy of tables from Inventory.
> 
> Problem:- Now when i call the second 'mysql_select_db', function, the query 
> failed to 
recognize the tables of the first database connection.
> 
> I have also checked the connection state, the connections remain active for 
> both cases 
till end.
>    
>   Below is the actual code:
> 
> 
> 
> 
> <?php
> 
> ///////// connection establishment with first database /////////////
> 
> $dbhost1 = '192.168.1.11';
> $dbuser1 = 'usman';
> $dbpass1 = 'ti123';
> $dbname1 = 'Inventory';
> $conn1 = mysql_connect($dbhost1, $dbuser1, $dbpass1); 
> mysql_select_db($dbname1, $conn1);
> 
> 
> ////////// connection establishment with second database 
> ///////////////////////
> 
> $dbhost = 'localhost';
> $dbuser = 'root';
> $dbpass = 'acbl';
> $dbname = 'tac';
> $conn = mysql_connect($dbhost, $dbuser, $dbpass);
> mysql_select_db($dbname, $conn);
> 
> 
> ///////////////// i want to exectue this query, using both databases but it 
> fail to 
recognize the
> //////////////// Inventory database tables 
> 
> $sql = "SELECT tac.casemain.CaseID, tac.casemain.BranchID from tac.casemain 
> INNER 
JOIN Inventory.branch ON tac.casemain.BranchID = Inventory.branch.branch_code";
> 
> 
> $result=mysql_query($sql, $conn) or die("cannot execute the query " . 
> mysql_error());
> $num=mysql_num_rows($result);
> echo "No: $num";
> ?>
> 
> 
>          
> 
> 
>        
> ---------------------------------
> Looking for a deal? Find great prices on flights and hotels with Yahoo! 
> FareChase.
> 
> [Non-text portions of this message have been removed]
>


Reply via email to