2012-11-12 49 views
0

我有一個包含一些表的數據庫。我想創建一個觸發器「刪除記錄在tblplayersfield與在tblplayers刪除的記錄的‘PID’」在MySQL中創建觸發器時遇到問題

CREATE TRIGGER delete_from AFTER DELETE on tblplayers 
FOR EACH ROW 
BEGIN 
DELETE FROM tblplayerfields 
    WHERE 'tblplayerfields'.'pID' = OLD.'pID'; 
END 
+1

而你的問題是? –

回答

0

您需要添加一個分隔符改變第一

delimiter | 

CREATE TRIGGER delete_from AFTER DELETE on tblplayers 
FOR EACH ROW 
BEGIN 
DELETE FROM tblplayerfields 
    WHERE 'tblplayerfields'.'pID' = OLD.'pID'; 
END 
| 
delimiter ; 

分隔符向數據庫引擎發出聲明結束的信號。通常是;。但是,這會在第一個;結束存儲過程。其定義不完整。

您可以更改分隔符並將其添加到過程的末尾。之後,將分隔符更改回;