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 字段中清除查询字符串.....
有什么想法吗 ?
您的日期比较是错误的。你基本上是在尝试
3 = '2013-01-18 10:36:00'
您需要将苹果与苹果进行比较:
MONTH(domain_usage.login_date) = MONTH(now())
修改你的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())