How to add column values in mysql
Sum is a aggregate function. You dont need to use it. This is the simple query -
select *,(maths + chemistry + physics ) AS total FROM `student`
Tip: If one of the fields has the possibility to be NULL, then use COALESCE to default these to 0, otherwise total
will result in NULL.
SELECT *, (
COALESCE(maths, 0) +
COALESCE(chemistry, 0) +
COALESCE(physics, 0)
) AS total
FROM `student`