Unexpected BLOB results with MySQL testing NULL variable with IFNULL, COALESCE
问题 In trying to test whether a variable has been defined, I discovered that the IF, IFNULL, and COALESCE statements return simply BLOB rather than the value I expected when (a) the variable has not been defined or (b) it has been explicitly set to NULL before being assigned a value in the session. I've verified this in MySQL versions 5.7 and 8.0. SELECT IF(@p IS NULL, 'is null', 'not null'); # 'is null' SELECT IF(@p IS NULL, 'is null', @p); # BLOB SELECT IFNULL(@p, 'is null'); # BLOB SELECT