MySql 中的触发器有问题。
notifications_posts
notification_id from_user on_post_id in_group_id date
2 1 162 3 2012-07-11 12:01:08
3 19 163 1 2012-07-11 12:03:26
4 19 164 1 2012-08-10 17:42:36
5 1 165 3 2012-08-29 12:14:01
6 1 165 3 2012-08-29 12:14:29
11 1 2 3 2012-08-29 14:38:42
有时我需要删除帖子,例如使用以下命令:
DELETE FROM posts WHERE posts.post_id = 165;
notification_id
在此之后,我想要一个根据该 ID删除所有记录的触发器。
这是我到目前为止所拥有的:
DELIMITER $$
CREATE OR REPLACE TRIGGER CleanNotificationPosts
AFTER DELETE ON posts
FOR EACH ROW
BEGIN
DELETE FROM notifications_posts WHERE notifications_posts.id = THAT_ID_TO_DELETE;
END $$
DELIMITER ;
我的语法正确吗?我真的需要分隔符吗?