我想这样做每次自己的系统make从storelte_notifications添加到storelte_usernotifications我的通知,但是当我的触发器尝试将它们插入另一个表时,它是第一个插入好,但第二个不插入,它还复制数据在我的第二张桌子上,我该如何解决?这就是我的触发器的样子
CREATE
DEFINER=`root`@`localhost`
TRIGGER `storelte`.`user_notification`
AFTER INSERT ON `storelte`.`storelte_notifications`
FOR EACH ROW
INSERT INTO storelte_user_notifications
SELECT storelte_notifications.user_id, NEW.id, NEW.timestamp,0
FROM storelte_notifications
答案 0 :(得分:0)
我不明白你选择的原因 - 也许这就是你的意图
CREATE
DEFINER=`root`@`localhost`
TRIGGER `storelte`.`user_notification`
AFTER INSERT ON `storelte`.`storelte_notifications`
FOR EACH ROW
INSERT INTO storelte_user_notifications
values (NEW.user_id, NEW.id, NEW.timestamp,0)