I have two database (connections to two servers), database1 and database2. Is there a way for a trigger function in a table in database1 to access a table in database2? If this is possible, how can I do it? Thanks in advance.
Asked
Active
Viewed 552 times
2 Answers
3
If you are using Mysql Federated Engine, then the answer is yes.
How to create linked server MySQL
Best regards
-
Isn't that for separate servers? I think the OP is talking about different databases on the same server. – Cylindric May 24 '12 at 15:35
-
1Yes, the question was edited, now it states clearly "connections to two servers". – Oscar May 24 '12 at 15:44
-
Aah, I missed that bit, sorry! – Cylindric May 24 '12 at 15:45
0
I'm not sure about triggers, but in normal queries you can just use the databasename.tablename syntax.
SELECT *
FROM `DatabaseA`.`Table1` t1
INNER JOIN `DatabaseB`.`Table1` t2 ON (`t1`.`id` = `t2`.`id`)

Cylindric
- 5,858
- 5
- 46
- 68