我如何结合以下内容:
IF( IF(news_publish_until IS NOT NULL,
news_publish_until, NOW())
>= NOW(),1,0)
IF( IF(news_publish_until IS NOT NULL,
news_publish_until, NOW())
<= NOW(),1,0)
如果条件为TURE,则SQL必须返回1,IE属于Publish from / until日期。此外,如果日期为空,则设置NULL而不是0000-00 ....
这是我到目前为止所处的位置:
IF(news_publish_from >= NOW() AND (news_publish_until >= NOW() OR news_publish_until IS NULL), 1,
IF(news_publish_from >= NOW() AND (news_publish_until <= NOW() OR news_publish_from IS NULL), 1, 0))
答案 0 :(得分:0)
select *,
(news_publish_from <= now() or news_publish_from is null) and
(news_publish_until >= now() or news_publish_until is null)
as result
from supportContacts
所以,我认为你应该把它放在你的sql
标签中:
news_publish_from <= now() or news_publish_from is null) and
(news_publish_until >= now() or news_publish_until is null)
你可以玩它here。希望这有帮助