这是我的表格数据学生
这是我的查询--
SELECT id, SUM( maths + chemistry + physics ) AS total, maths, chemistry, physics
FROM `student`
但它只抛出一行 --
id total maths chemistry physics
118 760 55 67 55
虽然我想为所有 id 应用 sum ....让我知道如何实现这一点?
最佳答案
Sum 是一个聚合函数。你不需要使用它。这是简单的查询 -
select *,(maths + chemistry + physics ) AS total FROM `student`
关于mysql - 如何在mysql中添加列值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12387061/