$db_query = mysqli_query($link, "Select Name, BriefDescription, SUM(Runs) as Runs
FROM BaseTable
WHERE RunDate >= DATE_ADD(day, -$dataRange, getdate() ) AND RunDate <= getdate()
GROUP BY Name, BreifDescription");
我收到的错误消息是
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 '-30, getdate() ) AND RunDate <= getdate() GROU' at line 3
我很困惑我的错误在哪里
答案 0 :(得分:0)
$db_query = mysqli_query($link, "Select Name, BriefDescription, SUM(Runs) as Runs
FROM BaseTable
WHERE RunDate >= (CURDATE() - INTERVAL $dataRange day) AND RunDate <= CURDATE()
GROUP BY Name, BreifDescription");
更改为使用CURDATE()和间隔似乎解决了这个问题。
答案 1 :(得分:-1)
DATE_ADD只有2个参数,你有3个。
date_add(day,offset)