Join tables from two different server

Yes, it is possible in MySQL.

There are similar questions asked previously too. You have to use FEDERATED ENGINE to do this. The idea goes like this:

You have to have a federated table based on the table at another remote location to use the way you want. The structure of the table have to exactly same.

CREATE TABLE federated_table (
    id     INT(20) NOT NULL AUTO_INCREMENT,
    name   VARCHAR(32) NOT NULL DEFAULT '',
    other  INT(20) NOT NULL DEFAULT '0',
    PRIMARY KEY  (id),
    INDEX name (name),
    INDEX other_key (other)
)
ENGINE=FEDERATED
DEFAULT CHARSET=latin1
CONNECTION='mysql://fed_user@remote_host:9306/federated/test_table';

[Source Answer]

Leave a Comment