2012-02-16 86 views
1

如何讓這個sqlite觸發器與MYSQL兼容,我從來沒有使用MYSQL的觸發器,我很困惑。使MYSQL的SQLITE觸發器工作

   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

CREATE TRIGGER語法 - http://dev.mysql.com/doc/refman/5.5/en/create-trigger。 html – Devart 2012-02-16 08:29:57

回答

1

未驗證:

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

我玩過它並找到了一個解決方案,謝謝大家嘗試 – dead 2012-02-16 08:46:27