trigger不能在mysql工作台上运行

eqqqjvef  于 2021-06-25  发布在  Mysql
关注(0)|答案(1)|浏览(335)

我更新了我的问题,仍然有问题。现在它显示了一个接近数值的红十字。我不知道语法有什么问题

DELIMITER $$

CREATE TRIGGER PendingPublish 
    AFTER INSERT ON TopicPending
    FOR EACH ROW
BEGIN
INSERT INTO Topics (Title,Description,Question1,Qustion2,Question3,Question4,UserID)
VALUES (NEW.Title,NEW.Descritpion,NEW.Question1,NEW.Question2,NEW.Question3,NEW.Question4,NEW.UserID) 
  FROM TopicPending  
  WHERE NEW.TopicApproved = 'YES' 
END;$$

DELIMITER ;
093gszye

093gszye1#

触发器具有表topicpending中的新值,因此要访问列topicapproved,只需在其前面加上new。无需选择。见下文。

IF NEW.TopicApproved = 'YES' THEN
  INSERT INTO Topics (Title,Description,Question1,Qustion2,Question3,Question4,UserID)
  VALUES (NEW.Title,NEW.Description,NEW.Question1,NEW.Question2,NEW.Question3,NEW.Question4,NEW.UserID);
END IF;

相关问题