faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

22 of 128 people (17%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

How can I query 2 MySQL databases on 2 different hosts (I have to join 2 tables on 2 different db)?

Sep 13th, 2000 16:26
Narendra Jain, Giovanni Bechis, unknown unknown,


You have to define 2 sets of database connections as given below:
mydata1=mysqldatabase($mydb1, $myname1, $mypass1);
mydata2=mysqldatabase($mydb2, $myname2, $mypass2);
Then you could have 2 different sql commands to pick data from the 2
databases as given below:
myquery1=mysqlquery($mydata1,"select count(*) from users");
myquery2=mysqlquery($mydata2,"select count(*) from tables");
After this $myquery1 and $myquery2 will have 2 results from queries from
2 different databases.