Mysql 触发器正在复制数据
我想这样做从storelte_通知添加到storelte_用户通知每次自己的系统发出我的通知时,但是当我的触发器尝试将它们插入到另一个表时,第一个插入很好,但第二个插入不好,它也会复制第二个表上的数据,我如何修复它?这就是我的触发器的样子Mysql 触发器正在复制数据,mysql,triggers,Mysql,Triggers,我想这样做从storelte_通知添加到storelte_用户通知每次自己的系统发出我的通知时,但是当我的触发器尝试将它们插入到另一个表时,第一个插入很好,但第二个插入不好,它也会复制第二个表上的数据,我如何修复它?这就是我的触发器的样子 CREATE DEFINER=`root`@`localhost` TRIGGER `storelte`.`user_notification` AFTER INSERT ON `storelte`.`storelte_notifications` FOR E
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
我不明白你为什么要从中选择-也许这就是你想要的
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)