Syntax:
IF(expr1,expr2,expr3)

If expr1 is TRUE (expr1 <> 0 and expr1 IS NOT NULL), IF() returns
expr2. Otherwise, it returns expr3.

*Note*:

There is also an IF statement, which differs from the IF() function
described here. See [HELP IF statement].

If only one of expr2 or expr3 is explicitly NULL, the result type of
the IF() function is the type of the non-NULL expression.

The default return type of IF() (which may matter when it is stored
into a temporary table) is calculated as follows:

o If expr2 or expr3 produce a string, the result is a string.

  If expr2 and expr3 are both strings, the result is case-sensitive if
  either string is case-sensitive.

o If expr2 or expr3 produce a floating-point value, the result is a
  floating-point value.

o If expr2 or expr3 produce an integer, the result is an integer.

URL: https://dev.mysql.com/doc/refman/8.0/en/flow-control-functions.html

