Quote:
AND (date_from <> '0001-01-01' or NOT(date_to IS NULL))
AND (date_to = '0001-01-01' or date_to IS NULL)
|
"or" should be "AND", like this...
AND (date_from <> '0001-01-01'
AND NOT(date_from IS NULL))
AND (date_to = '0001-01-01' or date_to IS NULL)
If "date_from <> '0001-01-01'" is true, it implies date_from IS NOT NULL.
(If date_from is null, "date_from <> '0001-01-01'" is UNKNOWN.)
So, this will be enough.
AND date_from <> '0001-01-01'
AND (date_to = '0001-01-01' or date_to IS NULL)