Php 是否检索列中少数选定行的总和?
我试图在数据库中获取选定的几行Money列的总和 下面是sql语句Php 是否检索列中少数选定行的总和?,php,mysql,sql,database,Php,Mysql,Sql,Database,我试图在数据库中获取选定的几行Money列的总和 下面是sql语句 $sql_total_money = "SELECT SUM(Money) as TotalMoney FROM accounts WHERE Program='PSC' BranchId='13' and ExamYear='2013'"; $result_total_money=mysql_query($sql_total_money,$link)or die($sql_total_money."<br/><
$sql_total_money = "SELECT SUM(Money) as TotalMoney FROM accounts WHERE Program='PSC' BranchId='13' and ExamYear='2013'";
$result_total_money=mysql_query($sql_total_money,$link)or die($sql_total_money."<br/><br/>".mysql_error());
$row_total_money=mysql_fetch_array($result_total_money);
我能做什么?解决方法是什么?您错过了
和程序
之后的:
SELECT SUM(Money) as TotalMoney
FROM accounts
WHERE Program='PSC'
AND BranchId='10'
AND ExamYear='2013'
您错过了一个和程序
之后的:
SELECT SUM(Money) as TotalMoney
FROM accounts
WHERE Program='PSC'
AND BranchId='10'
AND ExamYear='2013'
您需要使用条件运算符和/或类似的
SELECT SUM(Money) as TotalMoney
FROM accounts
HAVING Program='PSC' and
BranchId='10' and
ExamYear='2013'
您需要使用条件运算符和/或类似的
SELECT SUM(Money) as TotalMoney
FROM accounts
HAVING Program='PSC' and
BranchId='10' and
ExamYear='2013'
请,请,请停止使用mysql.*
。出于安全和其他原因,请改用PDO或mysqli。检查并请,请,请停止使用mysql.*
。出于安全和其他原因,请改用PDO或mysqli。检查一下,谢谢@mishik我没有看到,为此我被困了一个小时…无论如何谢谢…@user2557992-感谢并支持你可以接受答案。@user2557992如果这对你有用,你应该接受答案。…)谢谢@mishik我没有看到,为此我被困了一个小时…无论如何谢谢…@user2557992-感谢并支持你可以接受答案。@user2557992如果这对你有用,你应该接受答案。…)