且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在MySQL中创建触发器时遇到问题

更新时间:2023-10-09 09:16:52

您需要先添加定界符更改

You need to add a delimiter change first

delimiter |

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

定界符向DB引擎发出语句结束的信号.通常是; .但这将在第一个; 处结束存储过程.其定义将是不完整的.

The delimiter signals the DB engine the end of your statement. Normally it is ;. But that would end the stored procedure at the first ;. And its definition would be incomplete.

您可以更改定界符并将其添加到过程的末尾.之后,将分隔符改回;

You can change the delimiter and add it to the end of your procedure. After that change the delimiter back to ;