想要仅删除相关记录

时间:2017-06-29 12:37:45

标签: sql

当我从父表中删除记录时,我有这个触发器删除Jr.表的所有记录但我只想删除相关记录什么是建议的修改

CREATE TRIGGER ProductDeleted ON Product 
for DELETE AS 
BEGIN 

 DELETE FROM OrderItem WHERE ProductID = (SELECT ProductID FROM DELETED)
END

0 个答案:

没有答案