0

我有以下情况

  1. 用户从谷歌访问该网站,我们将此信息记录在数据库表“visitSearchEngine”中。如果用户注册,那么他的状态是活动的,即 1 ,如果他没有,那么他的状态变为非活动的,即 0 。所以,我需要一个查询。如果用户访问该站点并且没有在 10 分钟内注册,那么列出这些用户。

    我写了一个以下查询,但它不工作

    select distinct(users) , avisitedDate from visitSearchEngine vs
    WHERE vs.users!=' ' 
    AND vs.status='0' 
    AND hitType='googleIdentified'
    AND avisitedDate>'2012-12-06' 
    AND minute(timediff(now(),avisitedDate))>=10
    AND minute(timediff(now(),avisitedDate))<11
    
    //avisitedDate is Today's date. 
    

我想计算 currentTime 和visitedDate 之间的差异,如果是 10 分钟,则列出这些用户。

谢谢,

4

3 回答 3

1

我想你想要的是time_to_sec

select distinct(users) , avisitedDate from visitSearchEngine vs
WHERE vs.users!=' ' 
AND vs.status='0' 
AND hitType='googleIdentified'
AND avisitedDate>'2012-12-06' 
AND time_to_sec(timediff(now(),avisitedDate))>=10*60
AND time_to_sec(timediff(now(),avisitedDate))<11*60
于 2012-12-06T22:24:34.047 回答
0

试试这个 ::

select distinct(users) , avisitedDate from visitSearchEngine vs
WHERE vs.users!=' ' 
AND vs.status='0' 
AND hitType='googleIdentified'
AND DATE(avisitedDate)>'2012-12-06' 
AND minute(timediff(now(),avisitedDate))>=10
AND minute(timediff(now(),avisitedDate))<11
于 2012-12-06T12:48:59.317 回答
0

得到了答案,使用了 time_to_Sec ......它显示了......

select distinct(users) , avisitedDate from visitSearchEngine vs
WHERE vs.users!=' ' 
AND vs.status='0' 
AND hitType='googleIdentified'
AND DATE(avisitedDate)>'2012-12-06' 
AND ((time_to_Sec(timediff(now(),avisitedDate)))/60)>=5
AND ((time_to_Sec(timediff(now(),avisitedDate)))/60)<6
于 2012-12-07T12:33:51.980 回答