How to write a MySQL query on 2 different tables located in two different databases on two different servers?

I have 2 tables

table1 in database1 on server1 having userID and userName

table2 in database2 on server2 with user id

I need a way to access table1 on server1 to get username userID in table2

How to execute a query using MySQL?

+3
source share
3 answers

I think you can use 2 different connections:

$connection1= mysql_connect('server1', 'user1', 'password1');
$connection2= mysql_connect('server2', 'user2', 'password2');

Extract data from database 1 and use it to query database 2. Or vice versa, depending on what you need. This means that you will use 2 queries.

: , php, , . , .

+2

MySQL - , . , .

+1

not sure about mysql ...

in Oracle, you would link the databases and then fully qualify the links in the table in your query (with delimiters ".")

0
source

All Articles