茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1730275 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_00002.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

DB研討會 : [轉貼]MySQL Cross Server Select Query

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15773
[轉貼]Join tables from two different server(MySql)
Join tables from two different server

I have two different server server1 and server2, now I have db1 in server1 and db2 in server2. I am trying to join these two table in MySQL like this.
Select a.field1,b.field2
FROM  [server1, 3306].[db1].table1 a
Inner Join [server2, 3312].[db2].table2 b
ON a.field1=b.field2

But I am getting error. Is is possible in MYSQL.



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]

原文出處:mysql - Join tables from two different server - Stack Overflow
前一個主題 | 下一個主題 | | | |

討論串




Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|