Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

php - 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? 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");

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...