Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 触发器正在复制数据_Mysql_Triggers - Fatal编程技术网

Mysql 触发器正在复制数据

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

我想这样做从storelte_通知添加到storelte_用户通知每次自己的系统发出我的通知时,但是当我的触发器尝试将它们插入到另一个表时,第一个插入很好,但第二个插入不好,它也会复制第二个表上的数据,我如何修复它?这就是我的触发器的样子

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)