我有两个盒子和盒子存档用于此目的我写了triger,当用户删除框和盒子存档表数据为此目的更新时,将数据从box移动到box_archived表我写了下面的mysql触发器但是当我删除框然后我收到以下错误
SQLSTATE[HY000]: General error: 1442 Can't update table 'box' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. (SQL: update `box` set `archive` = 1, `updated_at` = 2018-04-06 07:31:57 where `id` = 48116 and `user_id` = 87)
下面是我在phpmyadmin MySql中编写的触发器代码
DROP TRIGGER IF EXISTS `move_archived_box`;CREATE DEFINER=`root`@`localhost` TRIGGER `move_archived_box` AFTER UPDATE ON `box` FOR EACH ROW begin
insert into box_archived
select * from box where archive = 1;
delete from box where archive = 1;
end;
我也只在只有存档列更新时运行触发器