我會開始,我在phpMyAdmin用mysql。SQL觸發從一個表到另一個時更新
我的表:
表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'的數據類型?你得到的錯誤是什麼? – bonCodigo
你應該描述表格和你得到的錯誤 – Matteo
是啊對不起,在這裏:我沒有具體,我認爲它很重要。 的table1的是人們的數據庫(如ID(唯一),姓名,電話,他的工資(cash1)等),表2是事物(ID,姓名,cash2)和表3列表劃分兩個值表。 我試着這樣做: CREATE TRIGGER試驗後,UPDATE table1的或表2 AS BEGIN UPDATE表3 SET table3.cash3 = table1.cash1 * table2.cash2/100 WHERE table3.cash3 = table1.cash1 *表2。 cash2/100 END; $$ 如果我做了2個觸發器,代碼的外觀如何? – trinny