gpt4 book ai didi

mysql - 如何在mysql中添加列值

转载 作者:IT老高 更新时间:2023-10-28 23:46:15 27 4
gpt4 key购买 nike

这是我的表格数据学生

enter image description here

这是我的查询--

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com