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 に答える