我试图在日期选择器中显示用户选择的 2 个日期之间的一些数据,但我没有找到正确编写查询的方法。,总是得到这个错误:
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 'BETWEEN2013-04-14AND2013-04-15GROUP BY created_at ORDER BY created_at' at line 1
这是我到目前为止写的:
$sd=$_POST['sd'];
$ed=$_POST['ed'];
$query = mysql_query("SELECT count(name) As Subscribers,CAST(`created_at` AS DATE) As Date FROM gcm_users WHERE created_at BETWEEN".$_POST['sd']."AND".$_POST['ed']."GROUP BY created_at ORDER BY created_at")or die(mysql_error());