选择本周日期为何的数据?

时间:2012-11-26 20:45:58

标签: mysql

如何限制我的SQL仅包含本周的数据? (星期一到星期日)

想到:

SELECT * FROM log WHERE timestamp >= timestamp - INTERVAL 7 DAY && DAYOFWEEK(timestamp-INTERVAL 7 DAY) > 2

但有些事情不对......

1 个答案:

答案 0 :(得分:1)

SELECT * FROM log 
WHERE yearweek(curdate()) = yearweek(timestamp)

YEARWEEK