mysql if condition code example
Example 1: mysql else if
IF condition1 THEN
statements;
ELSEIF condition2 THEN # OPTIONAL
statements;
ELSE # OPTIONAL
statements;
END IF;
Example 2: mysql if else
IF condition THEN
statements;
ELSE
else-statements;
END IF;
Example 3: mysql if statement in where clause
SELECT `id` , `naam`
FROM `klanten`
WHERE IF(`email` != '', `email`, `email2`) LIKE '%@domain.nl%'