Reputation: 53
I have this sql command that sums up the value from a,b,c and d. and i want it to be stored in my table in the column total. Is this the correct query? How to store the total value?
$sql = "SELECT sum(a + b + c + d) as total_value FROM tablename WHERE form_no = '$formnumber'";
Upvotes: 0
Views: 42
Reputation: 17406
$sql = "SELECT (a + b + c + d) as total_value FROM tablename WHERE form_no = '$formnumber'";
where a,b,c,d are column name..
This is working fine..check it
Upvotes: 0
Reputation: 781848
UPDATE tablename
SET total_value = a + b + c + d
WHERE form_no = '$formnumber'
Upvotes: 3