Click to See Complete Forum and Search --> : Calculating 2 Colums and returning value into 3rd Colum


psdeveloper
10-09-2008, 04:39 PM
I am new to mysql and have looked online, i have a table like this....
Quantity | Cost | Total_Cost ,

I want the total cost to = Quantity * Cost in the table, how do I do that.

Thanks

scragar
10-09-2008, 05:31 PM
SELECT `quantity`, `cost`, (`cost`*`quantity`) AS `total` FROM tableName WHERE condition

psdeveloper
10-09-2008, 07:52 PM
that look like a way to do it in php...is there a way to run automatically in mysql?

chazzy
10-09-2008, 09:02 PM
the code he posted is SQL.