2012-11-26 92 views
0

如何限制我的SQL僅包含本週的數據? (週一至週日)選擇本週日期的數據?

思想:

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

但有些事情是不正確的......

回答

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

YEARWEEK