簡體   English   中英

更新前的MySQL使用PhpMyAdmin觸發插入語法錯誤

[英]MySQL before update trigger an insert syntax error using PhpMyAdmin

 CREATE TRIGGER question_preserver BEFORE UPDATE ON bank
 FOR EACH ROW
 BEGIN
 IF TRIM(NEW.question) != TRIM(OLD.question) THEN
 INSERT INTO bank_question_history (id,old_question) VALUES (OLD.id,OLD.question)$$
 END IF$$
 END$$

我正在使用PHPMyAdmin的SQL窗口將查詢插入Mysql,使用的是$$ delim。 我收到錯誤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 5 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 5

我敢肯定這是顯而易見的事情,我只是想念它,但是無論我嘗試什么,我都無法使它工作。 該錯誤根本沒有幫助,根據我的研究,我正在像發現的4-5個示例一樣進行此操作。

任何幫助將不勝感激,謝謝!

去圖,我問了之后馬上想通了。

 CREATE TRIGGER question_preserver BEFORE UPDATE ON bank
 FOR EACH ROW
 BEGIN
 IF TRIM(NEW.question) != TRIM(OLD.question) THEN
 INSERT INTO bank_question_history (id,old_question) VALUES (OLD.`id`,OLD.`question`);
 END IF;
 END$$

你必須使用; 破壞每個語句/命令和您的delim $$以結束整個觸發器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM