mysql触发器问题
创建表时~需要第一个字段(id_1)自增长~第二个字段(id_2)的值等于第一个字段的值~
create table table_1 (
id_1 int primary key auto_increment,
id_2 int not null
);
为此目的编写触发器
|
create trigger t_table_i_ai AFTER INSERT ON table_1
for each row
BEGIN
UPDATE table_1 SET NEW.id_2 = NEW.id_1;
END
|
之后执行插入语句
insert into table_1 values (null,0);
错误如下~
ERROR 1442 (HY000): Can't update table 'module' in stored function/trigger because it is already used by statement which invoked this stored function/
trigger.
买高手解决~或请高手提出解决此问题更好的办法~