我怎样才能从昨天开始获取我的php命中?

时间:2013-12-14 01:40:23

标签: php

如果我使用这个php sql调用获得总点击量,我怎么能从昨天获得我的php命中。这是代码:

    SELECT *, COUNT(visitor_tracking.model_id) as model_count FROM user, visitor_tracking WHERE visitor_tracking.model_id = $user_id GROUP BY $user_id ORDER BY model_count DESC LIMIT 1

以这种方式插入数据日。这是代码:

2013-12-11 14:23:45

我的数据库名称是时间戳。

我怎样才能从昨天开始获取php命中?

2 个答案:

答案 0 :(得分:0)

您需要使用between。例如,这样的事情应该有效:

SELECT *, COUNT(visitor_tracking.model_id) as model_count 
FROM user, visitor_tracking 
WHERE visitor_tracking.model_id = $user_id AND 
    `timestamp` BETWEEN '2013-12-11 00:00:00' AND '2013-12-11 23:59:59' 
GROUP BY $user_id ORDER BY model_count DESC LIMIT 1

顺便说一下,由于使用了DESC LIMIT 1,我不确定您在该查询中是否需要COUNT,但我可能错了。

答案 1 :(得分:0)

WHERE created_time< '昨天00:00:00' AND created_time> DATE_ADD(CURDATE(),INTERVAL -1 天 ) 我希望它有所帮助