简体   繁体   English

查询捕获时间戳 0000-00-00 00:00:00

[英]Query capturing timestamp 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?如何让此查询不使用默认的 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.我以为我通过使用 0 获得了它,但它捕获了 0000-00-00 00:00:00。

$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");

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

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.该示例将获取您的日期不等于该值的所有行。

Capture Query where timestamp is 0000-00-00 00:00:00捕获时间戳为0000-00-00 00:00:00查询

To select rows select * from table_name where your_column = 0;要选择行select * from table_name where your_column = 0;

To update rows UPDATE table_name SET column_name = new_value where your_column = 0;更新行UPDATE table_name SET column_name = new_value where your_column = 0;

This will fix这将解决

mysql incorrect datetime value: '0000-00-00 00:00:00' mysql error mysql incorrect datetime value: '0000-00-00 00:00:00' mysql 错误

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

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