create trigger after_user_register
before INSERT on Users
for EACH ROW
begin
declare @id integer;
declare @userName varchar(30);
declare @userSurname varchar(30);
select
@id = userId,
@userName = userName,
@userSurname = userSurname
from
inserted;
insert into
UsersFullName
values(DEFAULT, @id, concat(@userName, @userSurname)) end
我的第一个声明出现#1064错误。您能帮我消除此错误吗?
答案 0 :(得分:1)
您的CREATE TRIGGER
遇到了一些问题。您可以使用以下更简单的解决方案:
DELIMITER //
CREATE TRIGGER after_user_register
AFTER INSERT on Users
FOR EACH ROW
BEGIN
INSERT INTO UsersFullName (id, fullname)
SELECT new.userId, CONCAT(new.userName, new.userSurname);
END
//
DELIMITER ;