mysql include null results

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mrlayance
Forum Commoner
Posts: 31
Joined: Mon Dec 07, 2009 11:53 am

mysql include null results

Post by mrlayance »

Not sure if this is possible but here goes. This is my query:

Code: Select all

SELECT `time`,`protocal`,(`octet`/1024) as `octet10243`,`percent`,`div`,FROM_UNIXTIME(`time`, '%Y-%m-%d') as `newtime3` FROM ipport WHERE FROM_UNIXTIME(`time`, '%Y-%m-%d') >= '2010-11-26' AND FROM_UNIXTIME(`time`, '%Y-%m-%d') <= '2010-11-30' AND (`protocal` = 'Echo' ) AND `div` = 'XDIV'
Results are as follows:

Code: Select all

"time";"protocal";"octet10243";"percent";"div";"newtime3"
"1290923100";"Echo";"92844.07421875";"1.04435";"XDIV";"2010-11-28"
"1291009500";"Echo";"95110.106445312";"1.0796";"XDIV";"2010-11-29"
Is it possible to include days that do not exist and give them the value 0? Even null would work. Not sure if some type of range command exists.
Desired results Example:

Code: Select all

"time";"protocal";"octet10243";"percent";"div";"newtime3"
"0";"Echo";"0";"0";"XDIV";"2010-11-26"
"0";"Echo";"0";"0";"XDIV";"2010-11-27"
"1290923100";"Echo";"92844.07421875";"1.04435";"XDIV";"2010-11-28"
"1291009500";"Echo";"95110.106445312";"1.0796";"XDIV";"2010-11-29"
"0";"Echo";"0";"0";"XDIV";"2010-11-30"
Thanks :banghead:
Post Reply