你可以试试
SELECT * FROM date JOIN
(SELECT CONVERT_TZ('2013-11-01 00:00:00','GMT','UTC') AS w1start,
CONVERT_TZ('2013-11-07 23:59:59','GMT','UTC') AS w1end,
CONVERT_TZ('2013-11-08 00:00:00','GMT','UTC') AS w2start,
CONVERT_TZ('2013-11-15 23:59:59','GMT','UTC') AS w2end,
CONVERT_TZ('2013-11-16 00:00:00','GMT','UTC') AS w3start,
CONVERT_TZ('2013-11-22 23:59:59','GMT','UTC') AS w3end) AS weeks
WHERE date BETWEEN w1start AND w1end
OR date BETWEEN w2start AND w2end
OR date BETWEEN w3start AND w3end
ORDER BY date DESC
这至少是一个开始。
但是,如果您想告诉应用程序满足三个条件中的哪一个,yiu 可能想要这样做
SELECT date BETWEEN w1start AND w1end AS firstweek,
date BETWEEN w2start AND w2end AS secondweek,
date BETWEEN w3start AND w3end AS thirdweek,
whatevercolumsyouneed
FROM date JOIN
(SELECT CONVERT_TZ('2013-11-01 00:00:00','GMT','UTC') AS w1start,
CONVERT_TZ('2013-11-07 23:59:59','GMT','UTC') AS w1end,
CONVERT_TZ('2013-11-08 00:00:00','GMT','UTC') AS w2start,
CONVERT_TZ('2013-11-15 23:59:59','GMT','UTC') AS w2end,
CONVERT_TZ('2013-11-16 00:00:00','GMT','UTC') AS w3start,
CONVERT_TZ('2013-11-22 23:59:59','GMT','UTC') AS w3end) AS weeks
HAVING firstweek OR secondweek OR thirdweek
ORDER BY date DESC
(未经测试;我不确定是否HAVING
放置正确。)