I"m using MySQL 5.5.37. I have this in a select statement ...
select (CASE s.end_date WHEN NULL THEN NOW() ELSE s.end_date END)
Your syntax is close, but a bit off. This is what you were trying to do:
SELECT CASE WHEN s.end_date IS NULL THEN NOW() ELSE s.end_date END FROM yourTable
But an easier and more concise way to handle possible
NULL values in your
end_date column would be to use the
SELECT COALESCE(s.end_date, NOW()) FROM yourTable
From the documentation for
Returns the first non-NULL value in the list, or NULL if there are no non-NULL values.
In terms of your query,
COALESCE will return
end_date if it isn't
NULL, and it will return
NOW() if it is