-1

在此处输入图像描述

这是我的数据库表数据,{我只维护一个表}

我将只获取当前一周的信息。

从每个 start_date 获取最多 3 个数据

给我任何开发查询的想法,

4

1 回答 1

0

尝试这个:

SELECT eventid, fkUserid, event_tags, event_title, event_description, start_date, end_date 
FROM (SELECT eventid, fkUserid, event_tags, event_title, event_description, start_date, end_date, 
            IF(start_date = @last, @auto:=@auto+1, @auto:=0) cnt, IF(start_date != @last, @last:=start_date, TRUE) test
        FROM (SELECT eventid, fkUserid, event_tags, event_title, event_description, DATE(start_date) start_date, end_date 
            FROM event WHERE DATE(start_date) BETWEEN '2012-12-14' AND '2012-12-20' ORDER BY start_date) AS A, 
          (SELECT @auto:=0, @last:='0001-01-01') AS B
        ) AS A
WHERE cnt < 3;
于 2012-12-20T10:02:48.540 回答