我有一个带timestamp列表,我想得到特定月份的时间戳(比如9月1日至9月30日)timpestamp),如果这个月是31天,这些值需要考虑。我使用以下查询:) `; z6 E9 p' H# y
SELECT users.username,users.id,count(tahminler.tahmin)as tahmins_no FROM users LEFT JOIN tahminler ON users.id = tahminler.user_id GROUP BY users.id having count(tahminler.tahmin) > 0我可以加where timestamp IN(dates_array)吗?? # g5 D F6 J) B' t7 jdate_array会是整个月的日期吗?% \+ C% h, m6 O& J9 f; d
3 D3 U* P) T' L4 J! ]8 P5 f: Z解决方案: 6 s& i0 J }! L SELECT users.username,users.id,count(tahminler.tahmin)as tahmins_no FROM users LEFT JOIN tahminler ON users.id = tahminler.user_id where year(timestamp) = 2013 and month(timestamp) = 9GROUP BY users.id having count(tahminler.tahmin) > 0要与索引一起使用,您可以执行它4 K& I. P! j* _6 P {
SELECT users.username,users.id,count(tahminler.tahmin)as tahmins_no FROM users LEFT JOIN tahminler ON users.id = tahminler.user_id where timestamp >= '2013-09-01' and timestamp