How to add column values in mysql

前端 未结 7 2002
醉话见心
醉话见心 2020-12-09 15:37

This is my table data Student

\"enter

And this is my query --

7条回答
  •  Happy的楠姐
    2020-12-09 16:28

    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`
    

提交回复
热议问题