我有id列表和相应的创建日期 例如:
1 2014-05-01
2 2014-07-01
3 2014-08-01
需要有关编写MySQL
select语句的建议,该语句在相应的创建日期之后提供id详细信息。
select id,count(*) from id_details where id IN(1,2,3) where resolved_at >(2014-05-01,2014-07-01,2014-08-01) group by id
答案 0 :(得分:0)
resolved_at
列的日期条件不正确。同样,如果您的查询中有两个WHERE
子句,那么这也是不正确的。您可以在>
子句中指定IN
条件,就像您正在尝试的那样。您的查询应该看起来像
select id,count(*)
from id_details
where id IN (1,2,3)
and (resolved_at >= '2014-05-01'
and resolved_at <= '2014-08-01')
group by id
我认为您只是尝试将IN
操作符用于resolved_at
列,如
select id,
count(*)
from id_details
where id IN (1,2,3)
and resolved_at IN ('2014-05-01','2014-07-01','2014-08-01')
group by id