I have two DATE-fields (PublishFrom, PublishTo) that are nullable. I am trying to get the records with this query:
SELECT * FROM tblNews
WHERE Publish = 1
AND IFNULL(PublishFrom, CURDATE() - INTERVAL 1 DAY) <= "2015-03-13"
AND IFNULL(PublishTo, CURDATE() + INTERVAL 1 DAY) >= "2015-03-13"
ORDER BY DateCreated DESC'
The meaning is that if the value of (one of) these fields is null, it is replaced by the value of yesterday and/off tomorrow so that the entry is always shown.
Right now I see only the posts where PublishFrom and/or PublishTo is not null. How come?