Reputation:
I want to multiply two columns( Quantity and Price) and produce the result in third column (Total). Please guide me how to do this.
Upvotes: 0
Views: 3036
Reputation: 1980
It is not recommended to store computed values in DB
. You can compute any time you need.
By any way for your need you can update it like this,
UPDATE TABLE_NAME set Total=Quantity*Price
You can also create triggers if needed,
CREATE TRIGGER triggername AFTER INSERT
ON TABLE_NAME
FOR insert
UPDATE TABLE_NAME SET TABLE_NAME.Total=TABLE_NAME.Quantity+TABLE_NAME.Price
Upvotes: 2