MYSQL从URL左侧字符串返回没有记录

时间:2013-01-18 16:36:07

标签: mysql string

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字段清理查询字符串.....

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

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

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

你需要比较苹果和苹果:

MONTH(domain_usage.login_date) = MONTH(now())

答案 1 :(得分: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())