SELECT
userid,
userName,
CASE userName
WHEN (userName IS NULL) THEN 'was null'
WHEN (userName IS NOT NULL) THEN 'was not null'
END AS caseExpressionTest
FROM
top_users
This does not give me the results I want. When the value is not null, I get 'was null', and when actually is null, I get an actual MYSQL NULL value. What I want is that when userName is null, return 'was null' and when userName is not null, return 'was not null'. What am I doing wrong here?
I am purposefully trying to do this with CASE expression, not an IF or IFNULL expression.
Using MYSQL 8.0.