使用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終端的單行中輸入提示 –