2

只需要获取当前周的记录。创建的列格式为“ 2013-11-13 00:00:00

SELECT COUNT( * ) AS con 
FROM  `accounts` 
WHERE  `description` LIKE  '%Earned%'   AND created = __________
4

2 回答 2

3

使用YEARWEEK()

SELECT COUNT( * ) AS con 
FROM  `accounts` 
WHERE  `description` LIKE  '%Earned%'   
AND yearweek(created) = yearweek(curdate())

SQLFiddle 演示

于 2013-11-13T10:07:37.557 回答
1
SELECT COUNT( * ) AS con 
FROM  `accounts` 
WHERE  `description` LIKE  '%Earned%'   AND
WEEK(created) = WEEK(curdate()) AND 
YEAR(created) = YEAR(curdate())
于 2013-11-13T10:11:04.743 回答