MySQL using BETWEEN comparison with NULL

后端 未结 3 1575
难免孤独
难免孤独 2021-01-05 15:58

I have a query with a where condition like so:

WHERE A.event_date BETWEEN B.start_date AND B.end_date

The complexity is that if B.sta

3条回答
  •  情话喂你
    2021-01-05 16:51

    IFNULL might help out here:

    WHERE A.event_date BETWEEN IFNULL(B.start_date,"1900-01-01") 
                       AND IFNULL(B.end_date,now());
    

提交回复
热议问题