I need help to create a trigger that can calculate prices after promotions. I have two tables "product" and "promotion". after inserting in promotion table the promotion price and the product id, I want to update the price in product table to the new price after promotion. here is my try :
CREATE TRIGGER update_promotion
AFTER INSERT ON promo
SELECT @prix_promo = prix_promotion FROM INSERTED;
SELECT @id = id_prod FROM INSERTED;
SELECT @prix_sanspromo = prix FROM produit
WHERE id_produit = @id;
FOR EACH ROW
UPDATE produit SET prix_promo=((@prix_promo*prix)/100) WHEREid_produit = @id;
promotion
andproduit
? Thank you.