This is my table data Student
And this is my query --
The sum function in MySQL works in the sense that it gives you the sum of values in a column from your select statement. If you need to sum values from a row in your query, then just use plus (+
) What you need is this query :
SELECT id, (`maths` +`chemistry`+`physics`) AS `total`, `maths`, `chemistry`, `physics`
FROM `student`;
This will give you the results you need.