mysql ifnull code example
Example 1: mysql else if
IF condition1 THEN
statements;
ELSEIF condition2 THEN # OPTIONAL
statements;
ELSE # OPTIONAL
statements;
END IF;
Example 2: mysql ifnull
##syntax:
SELECT IFNULL(col_with_null_value, default_value);
##you can see the result select with the string NA where the document is null:
SELECT IFNULL(user_document_id, 'NA');
Example 3: if column value is null then in mysql
SELECT
contactname, IFNULL(bizphone, homephone) phone
FROM
contacts;
Example 4: mysql select default if null
IFNULL(MAX(EMAIL), "[email protected]") as email