如何使触发器从两个不同表中的两个单独属性中读取,然后进行计算。
这是我想要制作的代码,但 mysql 说它有问题
CREATE TRIGGER `fee_calculate` BEFORE INSERT ON `BookingRoom`
FOR EACH ROW BEGIN
SET NEW.fee = `Booking.Night_Qty` * `Room.RoomPrice` ;
END
我认为它应该可以帮助你
我做了一些假设:
CREATE trigger updateprod on Products for update as begin 声明 @qtyonhand int, @reorder int if update(QtyonHand) begin select @qtyonhand = QtyonHand,@reorder = ReorderAmount from insert if @qtyonhand < @reorder begin update Reorders set ReorderAmount = @reorder, ReorderDate = getdate() end else if @qtyonhand >= @reorder begin 从重新订购中删除 ProductID = ProductID end end end