各位大佬,可以帮我找一下这个错在哪里吗?
代码是:
(一个人只能有一个email(这里暂且认为有一个‘@’,就代表有一个email))
drop trigger if exists insert_email $
create trigger insert_email
before insert on author
for each row
begin
set @one=(select locate(’@’,new.email)); #’@one’是’@‘第一次出现的位置,如果不出现’@’,则@one=0.
set @two=(select locate(’@’,new.email,@one)); #’@two’是’@‘第二次出现的位置,如果有第二个’@'则@two<>0
if (@one=0) then #如果@没有出现
select ‘error,your email does not have “@”’;
insert into error_email values(new.aid,new.email);
set new.email=‘error,please check table “error_email”’;
else if (@two<>0) then #如果有好几个@
select ‘error,an author can only have one email’;
insert into error_email values(new.aid,new.email);
set new.email=‘error,please check table “error_email”’;
end if;
end $
错误提示是:ERROR 1064 (42000): 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 16
谢谢大家!