0

I have a database with some tables. I want to create a trigger to 'Delete a record in tblplayersfield with "pID" of the record which was deleted in tblplayers'

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

1 回答 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 ;

定界符向数据库引擎发出语句结束的信号。通常是;. 但这将首先结束存储过程;。它的定义是不完整的。

您可以更改分隔符并将其添加到程序的末尾。之后将分隔符改回;

于 2012-11-12T18:00:24.843 回答