这就是我想要更改表2的值2并自动更新另一个表中的table1 value1。
DELIMITER $$
CREATE TRIGGER update_count2 AFTER update ON table2.value2
FOR EACH ROW
BEGIN
update table1.value1
join table2.value2 on foreignkeyoftable1 = primaryKeyftable2
join table3.value3 on primarykeyoftable3= foreignkeyoftable2
set table1.value1 = value2 * value3;
END $$
DELIMITER ;
答案 0 :(得分:0)
尝试这种触发器,并更新查询。
DELIMITER $$
CREATE TRIGGER update_count AFTER INSERT ON table1
FOR EACH ROW
BEGIN
update table1 t1
join table2 t2 on t1.id = t2.id
join table3 t3 on t1.id = t3.id
set t1.updateColumn = t2.value * t3.value
END $$
DELIMITER ;