3

I'm creating trigger that updates table in another database. This is trigger syntax:

CREATE TRIGGER `tbltrigger_after_update` AFTER UPDATE ON `tbl` FOR EACH ROW BEGIN
UPDATE db2.tbl1 SET db2.tbl1.Status = db1.tbl.Status WHERE db2.tbl1.OrderID = db1.tbl.OrderID;
END

But when I make change on Status field in db1.tbl I get error message 1054: Unkown column 'db2.tbl.OrderID' in 'where clause' even field exist in that table in db2.

What I'm doing wrong?

Josef
  • 2,648
  • 5
  • 37
  • 73

1 Answers1

2

Have a look at:

link1 - Trigger insert into new database

You might want to check this one as well

link2 - stack

p.s. - if the DB's are on different hosts , you probably need some sort of (custom) replication or federated-storage-engine

Community
  • 1
  • 1
ninjabber
  • 371
  • 2
  • 7
  • I've already saw this. There is no need for replication because both databases are on the same server. – Josef Sep 04 '14 at 08:27