使用MySQL 5.5,以下触发被拒一个错误:MySQL的触发器,模糊的语法错误
create trigger nodups
before insert on `category-category`
for each row
begin
if(catid >= relatedid) then
signal 'catid must be less than relatedid';
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 '-category for each row begin if(catid >= relatedid) then signal 'catid must be l' at line 1
什么是错的这个触发器的语法?
对于它的价值,我只是想阻止插入与catid >= relatedid
。我愿意接受实现这一目标的其他方法。
编辑: 上述被在一行上,分号和所有输入的查询。
我用分隔符重新尝试了一遍。这里是结果:
mysql> delimiter ###
mysql> create trigger nodups
-> before insert on `category-category`
-> for each row
-> begin
-> if(catid >= relatedid) then
-> signal 'catid must be less than relatedid';
-> 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 ''catid must be less than relatedid';
end if
end' at line 6
谢谢,我改变了它。仍然收到相同的错误 –
实际上,错误稍有不同:'错误1064(42000):您的SQL语法错误;检查与您的MySQL服务器版本相对应的手册,以便在第1行'end if end'附近使用正确的语法。 –
我在问题中添加了一个编辑...触发器正在MySQL终端的单行中输入提示 –