【发布时间】:2012-11-18 10:27:21
【问题描述】:
我将开始我在 phpmyadmin 中使用 mysql。
我的桌子:
表1:
primary key = id1;
cash1 = thing I want to pick from that table;
表2:
primary key = id2;
cash2 = thing I want to pick from that table;
表3:
foreign key1 = id1;
foreign key2 = id2;
cash3 = thing I want to make;
所以,我想做:
Update (or insert into?) cash3 = cash1*cash2/100 when UPDATE ON cash1 or cash2.
尝试了很多东西,似乎没有任何工作......
【问题讨论】:
-
你的
cash1和cash2的数据类型是什么?您遇到什么错误? -
您应该描述表格和您遇到的错误
-
是的,对不起,在这里:我没有具体说明,我认为这很重要。 table1 是人的数据库(如 id(唯一)、姓名、电话、他的薪水(cash1)等),Table2 是事物列表(id、name、cash2),table3 是划分这两个值的表。我试过这样做: CREATE TRIGGER test AFTER UPDATE table1 OR table2 AS BEGIN UPDATE table3 SET table3.cash3=table1.cash1*table2.cash2/100 WHERE table3.cash3=table1.cash1*table2.cash2/100 END; $$ 如果我做 2 个触发器,代码会是什么样子?
标签: mysql sql triggers phpmyadmin