这里我有3张桌子:
Book [Id] [UnitPrice]
BookOrder [Id] [BookId] [Quantity]
BookInvoice [Id] [OrderId] [TotalPrice]
然后,要求是从 Book 表中获取 UnitPrice。
UnitPrice * Quantity = TotalPrice
我是 SQL 的新手,这是我的代码:
CREATE TRIGGER TR_TotalPrice
ON BookInvoice *--Is that correct?*
FOR UPDATE, INSERT
AS
UPDATE BookInvoice SET TotalPrice = Book.Price * BookOrder.Number
FROM Book, BookOrder
……
而且我不知道如何完成这些代码,希望大家能帮助我,谢谢。