Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join Query From 2 Separate Databases on 2 Servers

Status
Not open for further replies.

likelylad

IS-IT--Management
Jul 4, 2002
388
GB
This is kind of half a PHP question and half a MySQL question.

I have 2 servers, both have information that is related to each.

Through PHP I would like run a query that will find matching data i.e. Inner Join

Can someone point me in the right direction of how this may be done, as I have only ever connected using something like the following code.

$db = mysql_connect("servername", "password");
mysql_select_db("databasename",$db);
$result = mysql_query("Select......",$db);

This only allows me to select tables from one database on one server.

I hope I am clear in explaining myself.

Thanking in advance for any help received

 
I don't think this is possible, since you get connected to only one DB server per variable. you can have:

$db1=mysql_connect("server1", "user","password");
$db2=mysql_connect("server2", "user","password");

so when you issue a query you do it only to one server:
mysql_query("SELECT * FROM table",$db1)
mysql_query("SELECT * FROM table",$db2)

Cheers.
 
I had a fair idea that this was the case but I was hoping some bright spark would be able to do it.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top