根据日期获取行数

时间:2014-11-25 04:01:25

标签: php mysql sql date

这是我使用的查询:

SELECT COUNT(*), categoryName 
FROM StuSelectCateg 
WHERE depName = 'Admisiones' timeOut>= '$Date1' 
      AND timeOut < '$Date2' 
GROUP BY categoryName

但它不会返回任何结果。

This is my Database

This is the output i want but with the dates

2 个答案:

答案 0 :(得分:1)

更改此行

where depName = 'Admisiones' timeOut>= '$Date1' and timeOut < '$Date2'

where depName = 'Admisiones'  and timeOut>= '$Date1' and timeOut < '$Date2'

and

之前您遗失了timeOut

答案 1 :(得分:-2)

您的查询不正确且缺少AND。请尝试以下查询

Select count(*), categoryName 
from StuSelectCateg 
where depName = 'Admisiones' and timeOut>= '$Date1' 
      and timeOut < '$Date2' 
group by categoryName