Two MYSQL databases available
One is 192.168.1.1 Port 3306 has a database DB1 a table TABLE1
One is 192.168.1.2 Port 3307 has a database DB2 a table TABLE2
192.168.1.1 remote connection 192.168.1.2 The user name Root1 password used by the database root1
192.168.1.2 remote connection 192.168.1.1 The user name Root2 password used by the database Root2
Now I want to TABLE1 and TABLE2 two tables to query how SQL should be implemented
There is no way to directly make a join query.
You can create a federated in DB1 to point to this db2.table2 as follows, and then act as if you were DB1 in the same database.
CREATE TABLETABLE2 (IDINT( -) not NULLauto_increment, nameVARCHAR( +) not NULL DEFAULT "', OtherINT( -) not NULL DEFAULT '0', PRIMARY KEY(ID),INDEXname (name),INDEXOther_key (Other)) ENGINE=FederatedDEFAULTCHARSET=latin1connection='Mysql://192.168.1.2:3307/db2/table2';
Or:
connection= ' Mysql://root2:[email protected]:3307/db2/table2 ';
From: http://bbs.csdn.net/topics/320196555
MySQL Cross-Library join