简体   繁体   English

仅从15分钟后选择

[英]SELECT only from 15 minutes back

I would likt to select text from chatlog which is max. 我想从聊天日志中选择文本,最大。 15 minutes old, but this doesn't work 15分钟前,但这不起作用

What am i doing wrong? 我究竟做错了什么?

My field "date" is 2013-01-04 22:50:53 我的栏位“日期”是2013-01-04 22:50:53

 select user 
 from chatlog 
 WHERE date  >= DATE_SUB(CURDATE(),INTERVAL 15 MINUTE) 
   AND  room = '".$roomId."' 
   and user != 35 
   and event_id IS NULL

Did also try <= instead of >= 也尝试了<=而不是>=

CURDATE only has a date component (not time). CURDATE仅具有日期成分(没有时间)。 You need to use NOW() instead. 您需要改为使用NOW()。

You need to use NOW() : 您需要使用NOW()

SELECT `user`
FROM chatlog
WHERE date > NOW() - INTERVAL 15 MINUTE
    AND room = '" . $roomId . "' 
    AND `user` != 35 
    AND event_id IS NULL

Try this: 尝试这个:

SELECT user FROM chatlog 
     WHERE date  >= NOW() - INTERVAL 15 MINUTE
     AND  room = '".$roomId."' 
     AND user != 35
     AND event_id IS NULL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM