查询捕获时间戳 0000-00-00 00:00:00 [英] Query capturing timestamp 0000-00-00 00:00:00

查看:50
本文介绍了查询捕获时间戳 0000-00-00 00:00:00的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让此查询不使用默认的 DatePercentUpdate = 0000-00-00 00:00:00 获取时间戳?我以为我通过使用 0 获得了它,但它捕获了 0000-00-00 00:00:00.

How do I get this query to not pick up timestamps with the default DatePercentUpdate = 0000-00-00 00:00:00? I thought I had it by using 0, but it captures the 0000-00-00 00:00:00's.

$stmtSummary = $mysqliSummary
    ->prepare("SELECT n.nodeID, n.percentRedYellow, n.count, c.Loopback_ip, c.city 
               FROM CATV.CableData  c 
               INNER JOIN CATV.node n ON n.nodeID = c.Node_ID   
               INNER JOIN CATV.CM cm ON cm.LoopbackIP=c.Loopback_ip
               WHERE c.LocationID IS NOT NULL 
                 AND c.Status_Update_Time <= NOW() 
                 AND c.Status_Update_Time >=(NOW() - INTERVAL 2 DAY) 
                 AND c.Status_Update_Time>0
                 AND n.DatePercentUpdate <= NOW() 
                 AND n.DatePercentUpdate >=(NOW() - INTERVAL 2 DAY) 
                 AND n.DatePercentUpdate>0
                 AND length(c.Node_ID)>0
               Group BY c.city, n.nodeID");

补充:我尝试在线搜索以在查询中使用 0000-00-00 00:00:00,但在过滤器中没有找到任何相关内容.

Added: I tried searching online to use 0000-00-00 00:00:00 in the query, but didn't find anything with that in a filter.

推荐答案

您可以简单地使用 >(大于)比较运算符或 !=(不't equal) 像这样的比较运算符

You can simply use the > (greater than) comparison operator or the != (doesn't equal) comparison operator like so

WHERE `date_field` != '0000-00-00 00:00:00'

该示例将获取您的日期不等于该值的所有行.

The example will get all rows where your date doesn't equal that value.

这篇关于查询捕获时间戳 0000-00-00 00:00:00的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆