我有三个议会议员,混乱和费率。
council_member(student_id, field2,...)
mess(mess_id,field2,...)
rates(student_id,mess_id,rating)
student_id和mess_id是外键。
费率存储每个理事会成员对每个混乱的评级。我想创建一个触发器,在插入一个新的理事会成员时,插入tupples到插入的student_id的表速率和每个mess_id乱七八糟的评级。
如何在每个mess_id的触发器中运行insert语句?
答案 0 :(得分:1)
这很棒
CREATE TRIGGER insert_council_member
AFTER INSERT ON council_member
FOR EACH ROW
INSERT INTO rates SELECT NEW.student_id, mess_id, 10 FROM mess;