0
SELECT
domain_usage.url,
LEFT(url,locate('?',url)) AS cleanURL
FROM
domain_usage
WHERE
MONTH(domain_usage.login_date) =  (Now()) AND
YEAR(domain_usage.login_date) =  (Now());

不返回任何记录,也没有错误?我试图从 URL 字段中清除查询字符串.....

有什么想法吗 ?

4

2 回答 2

1

您的日期比较是错误的。你基本上是在尝试

3 = '2013-01-18 10:36:00'

您需要将苹果与苹果进行比较:

MONTH(domain_usage.login_date) = MONTH(now())
于 2013-01-18T16:37:41.937 回答
0

修改你的WHERE条件,

SELECT domain_usage.url, LEFT(url,locate('?',url)) AS cleanURL 
FROM domain_usage
WHERE MONTH(domain_usage.login_date) = MONTH(CURDATE()) AND 
      YEAR(domain_usage.login_date) =  YEAR(CURDATE())
于 2013-01-18T16:37:25.707 回答