php数组在日期之间的SQL查询中

时间:2015-07-10 18:25:43

标签: php mysql

我有这个$ option数组([0] => 1 [1] => 4 [2] => 10)

我的查询是:

$query = "SELECT *  FROM table WHERE cc_classification IN ('" . implode("','",$options) . "') AND submit_date BETWEEN '2015-07-01 00:00:00' AND '2015-07-10 23:59:59'  ";

不确定这个查询有什么问题,但它没有给我任何结果。

我试图取出日期范围

$query = "SELECT *  FROM table WHERE cc_classification IN ('" . implode("','",$options) . "') "; 

它工作正常。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

试试这个。问题我不是在数组中,而是在sql语法中。

$query = "SELECT *  FROM table WHERE cc_classification IN ('" . implode("','",$options) . "') AND (submit_date BETWEEN '2015-07-01 00:00:00' AND '2015-07-10 23:59:59')  ";