我有两张表有一对多的关系
示例:
Table Buy : BuyID, BuyName
Table BuyItems: BuyItemID, Buy_BuyID, Quantity, Amount
现在我想创建触发器,所以每当用户插入表购买时,我都可以插入表:
Buy_Summary:
TotalQuantity(来自记录Buy.BuyID = BuyItems.Buy_BuyID的表BuyItems中所有数量的总和)
TotalAmount(来自记录Buy.BuyID = BuyItems.Buy_BuyID的表BuyItems中的所有金额的总和)
我该怎么做?