我刚接触到php& MySQL的。我有两个专栏,团队和mysql数据库中的日期。 我尝试使用代码来查找基于日期过滤器的总数。(即2013年8月6日)
$result = mysql_query("SELECT Date, SUM(issuedwt) AS IssuedTotal, SUM(receiptwt) AS ReceiptTotal, SUM(workloss) AS Balance FROM `worksheet` GROUP BY Date")
or die(mysql_error());
我得到了总数,但我也得到了2013年8月10日的总数。我不需要那个。有什么建议吗?
答案 0 :(得分:0)
$filter = "2013-08-10";
$sql = "SELECT Date,
SUM(issuedwt) AS IssuedTotal,
SUM(receiptwt) AS ReceiptTotal,
SUM(workloss) AS Balance
FROM `worksheet`
WHERE Date = '".$filter."'
GROUP BY Date";
$result = mysql_query($sql) or die(mysql_error());
答案 1 :(得分:0)
忽略date
子句中的select
字段。试试这个:
$result = mysql_query("SELECT SUM(issuedwt) AS IssuedTotal, SUM(receiptwt) AS ReceiptTotal, SUM(workloss) AS Balance FROM `worksheet` GROUP BY Date")
or die(mysql_error());