56,682
社区成员
发帖
与我相关
我的任务
分享
-- 在日期和物品上建立唯一索引
alter table new_table1 add unique(日期,物品);
-- 在 new_table 上建立触发器
create trigger tr_insert_new_table after insert on new_table for each row
insert into new_table1(日期,物品,合成材料1,合成材料2,合成材料3)
values(日期,物品,合成材料1,合成材料2,合成材料3
on duplicate key update
合成材料1=values(合成材料1)+合成材料1,
合成材料2=values(合成材料2)+合成材料2,
合成材料3=values(合成材料3)+合成材料3
;
-- 在日期和物品上建立唯一索引
alter table new_table1 add unique(日期,物品);
-- 在 new_table 上建立触发器
create trigger tr_insert_new_table after insert on new_table for each row
insert into new_table1(日期,物品,合成材料1,合成材料2,合成材料3)
values(new.日期,new.物品,new.合成材料1,new.合成材料2,new.合成材料3)
on duplicate key update
合成材料1=values(合成材料1)+合成材料1,
合成材料2=values(合成材料2)+合成材料2,
合成材料3=values(合成材料3)+合成材料3
;