如何运行sql查询php文件中两行或更多行的总和

问题描述 投票:1回答:2

如何在php中横向查询两个或多个列的总和。

假设我有类似的表格

srno   name   english  maths  science  TotalMarks
1      rohit  52       52     52           ?

所以如何获得所有标记的总和。并显示在总分字段中。通过php代码。

php mysql
2个回答
0
投票

尝试这样的事情:

SELECT srno, name, english, maths, science, (english+maths+science) As TotalMarks FROM `table_name`

还要检查此主题:How to SUM two fields within an SQL query


0
投票

尝试一下:

SELECT *,(英语+数学+科学)AS Total FROM表;

© www.soinside.com 2019 - 2024. All rights reserved.