MySQL中这个CREATE TRIGGER语句的语法有什么问题?

时间:2012-05-16 00:06:44

标签: mysql triggers

CREATE TRIGGER `lastedited` AFTER UPDATE ON `eng-jap`
FOR EACH ROW
BEGIN
UPDATE `mrhowtos_main`.`eng` 
SET `lastmodified` = CURRENT_TIMESTAMP WHERE `eng`.`english` = old.eng;
UPDATE `mrhowtos_main`.`jap` 
SET `lastmodified` = CURRENT_TIMESTAMP WHERE `jap`.`japanese` = old.jap;
END;

MySQL返回的错误是: MySQL说:文档

#1064 - You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '' at line 5 

1 个答案:

答案 0 :(得分:1)

#START TRIGGER
    delimiter $$
    CREATE TRIGGER `lastedited` AFTER UPDATE ON `eng-jap`
    FOR EACH ROW
    BEGIN
    UPDATE `mrhowtos_main`.`eng` 
    SET `lastmodified` = CURRENT_TIMESTAMP WHERE `eng`.`english` = old.eng;
    UPDATE `mrhowtos_main`.`jap` 
    SET `lastmodified` = CURRENT_TIMESTAMP WHERE `jap`.`japanese` = old.jap;
    END;
    $$

如果仍然无效,请尝试将静态值替换为old.eng和old.jap,例如“roma”