我有一个包含一些表的数据库。我想创建一个触发器'删除tblplayersfield中的记录,并在tblplayers'中删除记录的“pID”
CREATE TRIGGER delete_from AFTER DELETE on tblplayers
FOR EACH ROW
BEGIN
DELETE FROM tblplayerfields
WHERE 'tblplayerfields'.'pID' = OLD.'pID';
END
答案 0 :(得分:0)
您需要先添加分隔符更改
delimiter |
CREATE TRIGGER delete_from AFTER DELETE on tblplayers
FOR EACH ROW
BEGIN
DELETE FROM tblplayerfields
WHERE 'tblplayerfields'.'pID' = OLD.'pID';
END
|
delimiter ;
分隔符表示数据库引擎结束语句。通常是;
。但这会在第一个;
结束存储过程。它的定义是不完整的。
您可以更改分隔符并将其添加到过程的末尾。之后,将分隔符更改回;