Answer the question
In order to leave comments, you need to log in
How to create a mysql trigger to update a table in another database?
creation of tables test DB billing;
USE billing;
CREATE TABLE `test` (
`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`content` TEXT NOT NULL
) ENGINE = innodb;
USE billing_test;
CREATE TABLE `test` (
`id` INT( 11 ) UNSIGNED NOT NULL PRIMARY KEY,
`content` TEXT NOT NULL
) ENGINE = innodb;
use billing;
DELIMITER //
CREATE TRIGGER `update_test3` AFTER INSERT ON `test`
FOR EACH ROW
BEGIN
INSERT INTO `billing_test.test` set id = NEW.ID, content = NEW.content;
-- как правильно здесь указать таблицу из другой базы??????
END;
//
DELIMITER ;
INSERT INTO billing.test(content) VALUE("TEST NEW TRIGEER");
Answer the question
In order to leave comments, you need to log in
`billing_test.test` is the name of the table in the current database
`billing_test`.`test` is the test table in the billing_test database
Perhaps your code is just an example, but it has syntactical problems
The INSERT code should look different (in a trigger)
"Might help"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question