Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
对 table1 进行更新后,我想删除 table2 中的数据。但是,要删除 table2 中的数据,例如,我需要一个可以从 table1 上的更新中获得的 ID。我怎样才能做到这一点?
table1:table1_ID PK,column1,column2 table2:table2_ID PK,table1_ID FK,column 1
Wabbit,这个应该可以帮助你:
DELIMITER /// CREATE TRIGGER name_of_the_trigger AFTER UPDATE ON table1 FOR EACH ROW BEGIN DELETE FROM table2 t2 WHERE t2.table1_ID = OLD.table1_ID; END; /// DELIMITER ;