user379888
user379888

Reputation:

Multiply two columns and produce result in third column

I want to multiply two columns( Quantity and Price) and produce the result in third column (Total). Please guide me how to do this.

enter image description here

Upvotes: 0

Views: 3036

Answers (1)

Sridhar DD
Sridhar DD

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

Related Questions