我正在向用户显示当前周事件..从当前日期获取数据到当前日期值的 +7 天..它通过使用这些查询来实现
SELECT * from events WHERE ( start_date BETWEEN '2013-01-01' AND '2013-01-07' ) order by start_date ASC
我有问题,如果,
start_date 2013-01-01 have 10 records
start_date 2013-01-02 have 1 records
start_date 2013-01-03 have 12 records
....
...
然后从数据库中获取数据需要更多时间。所以,我每天只需要显示 3 个数据表
我的表,
id start_date end_date event_title
1 2013-01-01 2013-01-03 event_1
2 2013-01-01 2013-01-01 event_2
3 2013-01-01 2013-01-01 event_3
4 2013-01-01 2013-01-01 event_4
- 2013-01-01 2013-01-01 event_4
- 2013-01-01 2013-01-01 event_4
5 2013-01-02 2013-01-02 event_5
6 2013-01-03 2013-01-03 event_6
7 2013-01-03 2013-01-03 event_7
8 2013-01-03 2013-01-03 event_8
9 2013-01-03 2013-01-03 event_9
10 2013-01-04 2013-01-04 event_10
预期输出为 ,
id start_date end_date event_title
1 2013-01-01 2013-01-03 event_1
2 2013-01-01 2013-01-01 event_2
3 2013-01-01 2013-01-01 event_3
4 2013-01-02 2013-01-02 event_5
5 2013-01-03 2013-01-03 event_6
6 2013-01-03 2013-01-03 event_7
7 2013-01-03 2013-01-03 event_8
8 2013-01-04 2013-01-04 event_10
任何人都可以帮助解决这些... 可能在单个查询中