MySQL Cross-Library join

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.