DELIMITER $$
CREATE TRIGGER DELETETRIGGER AFTER DELETE ON WORKLOG
  FOR EACH ROW
  BEGIN
    INSERT INTO WORKLOGCOPY (Log_ID, Order_ID, Employee_ID, Client_ID,
Work_Completed, Hours_Taken, Date_Logged)
    VALUES(OLD.Log_ID, OLD.Order_ID, OLD.Employee_ID, OLD.Client_ID,
OLD.Work_Completed, OLD.Hours_Taken, OLD.Date_Logged)
  END$$
DELIMITER ;

我收到错误消息:
#1064 - 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
'END' at line 6

尝试弄乱语法以匹配我见过的示例,但是没有运气。

如果有帮助,请在phpmyadmin上使用MySQL。

谢谢。

最佳答案

您在;的末尾缺少INSERT INTO

DELIMITER $$
CREATE TRIGGER DELETETRIGGER AFTER DELETE ON WORKLOG
  FOR EACH ROW
  BEGIN
    INSERT INTO WORKLOGCOPY (Log_ID, Order_ID, Employee_ID, Client_ID,
Work_Completed, Hours_Taken, Date_Logged)
    VALUES(OLD.Log_ID, OLD.Order_ID, OLD.Employee_ID, OLD.Client_ID,
OLD.Work_Completed, OLD.Hours_Taken, OLD.Date_Logged);
  END$$
DELIMITER ;

关于mysql - 尝试创建触发器时遇到错误#1064即将结束,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53683098/

10-13 06:52