Mysql 插入phpmyadmin上的触发器

Mysql 插入phpmyadmin上的触发器,mysql,tsql,phpmyadmin,mysql-workbench,Mysql,Tsql,Phpmyadmin,Mysql Workbench,我是MySQL新手。我有两张表,分别是帖子和通知。我试图为帖子中添加的每一个新行创建一个触发器,我想将该新行添加到通知id中。 它在mysql上正常工作,但在phpmyadmin中触发器不会执行,它给出了一个错误 1064-您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解要使用的正确语法 在第11行的“”附近 下面是我的桌子的样子: 员额表 create table posts ( id int, topic_id tinyint, post_creator int, p

我是MySQL新手。我有两张表,分别是帖子和通知。我试图为帖子中添加的每一个新行创建一个触发器,我想将该新行添加到通知id中。 它在mysql上正常工作,但在phpmyadmin中触发器不会执行,它给出了一个错误

1064-您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解要使用的正确语法 在第11行的“”附近

下面是我的桌子的样子:

员额表

create table posts
(
id int,
 topic_id tinyint,
post_creator int,
post_date datetime,
post_content text
);
通知表

create table notification
(
    not_id int ,
    top_id tinyint,
    p_creator int,
    p_date datetime,
    p_content text
);
通知id触发器

delimiter $$;
    create trigger notification_id before Insert on posts
    for each row 
    begin
        declare id int;
        declare topic_id int;
        declare post_creator int;
        declare post_date datetime;
        declare post_content text;
    
        insert into notification(not_id,top_id,p_creator,p_date,p_content) values(new.id,new.topic_id,new.post_creator,new.post_date,new.post_content);
    end$$;
  • 通常先创建表
  • 更改phpmyadmin界面中的默认分隔符[它就在输入查询的文本框下方]
  • 单独运行创建触发器脚本,不更改分隔符行 因此,触发器的代码不应该有
    分隔符$$

  • 所以要明确的是,您已经创建了触发器,当您从MySQL执行插入时,它工作正常,但是从phpMyAdmin执行相同的插入失败,并显示错误消息?您是通过“插入”选项卡插入还是直接在SQL中键入?