使SQLITE Trigger与MYSQL一起使用

时间:2012-02-16 08:28:06

标签: php mysql sqlite

如何使这个sqlite触发器与MYSQL兼容,我从来没有使用MYSQL触发器,我很困惑。

             CREATE TRIGGER IF NOT EXISTS update_this AFTER INSERT ON this
             BEGIN
             UPDATE `another` SET `something` = `something` + new.number;
             END;

解决方案:

     delimiter |
     CREATE TRIGGER update_this AFTER INSERT ON this`
     FOR EACH ROW BEGIN
     UPDATE `another` SET `something` = `something` + NEW.something WHERE `id`= NEW.id;
     END;
     |    
     delimiter ;

1 个答案:

答案 0 :(得分:1)

未验证:

delimiter //
    CREATE TRIGGER update_this AFTER INSERT ON your_table
    BEGIN
        UPDATE `another` SET `something` = `something` + new.number;
    END;
//