你好我有这个总和的一些问题选择有没有人知道这有什么不对,似乎我没有得到它的结果
$result = mysql_query("SELECT SUM(total)
FROM table1 where date BETWEEN '".$date1." 00:00:00' AND '".$date2." 23:59:59' and username = ".$user."");
while($row=mysql_fetch_array($result))
{ $sum = $row['SUM(total)'];}
答案 0 :(得分:0)
尝试
$query = "SELECT SUM(total) AS result
FROM table1
WHERE DATE(date) BETWEEN '$date1' AND '$date2'
AND username = '$user'";
$con = \\your db connection string
$result = mysql_query($con,$query);
while($row=mysql_fetch_array($result))
{$sum = $row['result'];}