A condition is verified using the MySQL IF() function. If the condition is TRUE, the IF() function returns a value, and if the condition is FALSE, it returns a different value. Keep in mind that an IF statement differs from an IF function.
The IF function can return a string or a numeric value depending on how it is utilized.
Examples:
SELECT IF(100 < 200, 1, 0);
Result: 1
SELECT IF(‘hello’ = ‘Hello’, ‘TRUE’, ‘FALSE’);
Result: TRUE
SELECT IF(‘hello’ = ‘Hello’, “YES”, “NO”);
Result: YES
SELECT IF(STRCMP(“hello”,”Hell”) = 0, “YES”, “NO”);
Result: NO