目的就是让表里相同id只有一条数据(最后一条) 所以我建了个触发器 插入之前先删除已经存在的id的数据CREATE TRIGGER `autoDeleteOld` BEFORE INSERT ON `lastscore` FOR EACH ROW delete from lastscore where id = NEW.id
执行的时候报错: 1442 Can't update table 'lastscore' in stored function/trigger because it is already used by statement which invoked this stored function/trigger 求救......
执行的时候报错: 1442 Can't update table 'lastscore' in stored function/trigger because it is already used by statement which invoked this stored function/trigger 求救......
设置主键和唯一是可以用replace代替insert 可是为什么我那个触发器不行呢?
Old question, but in case anyone finds this: MySQL triggers can't manipulate the table they are assigned to. All other major DBMS support this feature so hopefully MySQL will add this support soon.
answered Feb 22 '10 at 21:16