I need the result that I got to be inserted in the right row.
DECLARE @DiscPrice float; SET @DiscPrice = (SELECT Prod.priceProd - Prod.priceProd / 100 * Prod.disc FROM Prod WHERE id_prod = 1); UPDATE Prod SET priceDisc = @DiscPrice WHERE id_prod = 1; SELECT * FROM Prod;
That is, instead of WHERE id_prod = 1
, there was something that inserted the desired result in all rows.
I’m not sure I made myself clear, but I hope that you will understand.
Advertisement
Answer
I think you want
UPDATE Prod SET priceDisc = ((priceProd - priceProd) / 100) * disc WHERE id_prod = 1;
There is no need to use a variable or a query to assign the value to it.