[英]How to create a trigger to insert new users details to another table?
Im trying to "synchronize" an external forum script (SMF) with my website. 我试图将一个外部论坛脚本(SMF)与我的网站“同步”。 Thats means, when a user registers in my website, a trigger insert the user details (username, password and email) in the external forum members table.
就是说,当用户在我的网站上注册时,触发器将在外部论坛成员表中插入用户详细信息(用户名,密码和电子邮件)。 Something like that, but its wrong, sql error.
那样的东西,但是它是错误的,sql错误。
CREATE TRIGGER forumReg
AFTER INSERT ON hotaru_users
FOR EACH ROW
BEGIN
INSERT INTO forum_members (member_name, email_address, passwd)
VALUES (NEW.user_username, NEW.user_email, NEW.user_password);
END
hotaru_users is my website users table, forum_members is the external forum users table, both tables are in the same mysql database hotaru_users是我的网站用户表,forum_members是外部论坛用户表,两个表都在同一个mysql数据库中
the error 错误
Erro
consulta SQL:
CREATE TRIGGER forumReg AFTER INSERT ON hotaru_users
FOR EACH
ROW
BEGIN
INSERT INTO forum_members( member_name, email_address, passwd )
VALUES (
NEW.user_username, NEW.user_email, NEW.user_password
);
Mensagens do MySQL : Documentação
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 6
Either remove the BEGIN
, END
: 删除
BEGIN
, END
:
CREATE TRIGGER forumReg
AFTER INSERT ON hotaru_users
FOR EACH ROW
INSERT INTO forum_members (member_name, email_address, passwd)
VALUES (NEW.user_username, NEW.user_email, NEW.user_password);
or change the delimiter for the creation of the trigger: 或更改用于创建触发器的定界符:
DELIMITER $$
CREATE TRIGGER forumReg
AFTER INSERT ON hotaru_users
FOR EACH ROW
BEGIN
INSERT INTO forum_members (member_name, email_address, passwd)
VALUES (NEW.user_username, NEW.user_email, NEW.user_password);
END
$$
DELIMITER ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.