help
help

Reputation: 851

Can a trigger function in one database access table in another database?

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.

Upvotes: 2

Views: 575

Answers (2)

Cylindric
Cylindric

Reputation: 5894

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`)

Upvotes: 0

Oscar
Oscar

Reputation: 13960

If you are using Mysql Federated Engine, then the answer is yes.

How to create linked server MySQL

Best regards

Upvotes: 3

Related Questions