我试图在数据库中获取几行选定的 Money Column 行的总和。
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/><br/>".mysql_error());
$row_total_money=mysql_fetch_array($result_total_money);
由于 die 功能,这会出现如下错误。
SELECT SUM(Money) as TotalMoney FROM accounts WHERE Program='PSC' BranchId='10' and ExamYear='2013'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'BranchId='10' and ExamYear='2013'' at line 1
我能做什么,解决方案是什么?