Syntax
IF(expr1,expr2,expr3)
Purpose
If expr1 is TRUE (that is, expr1 is not equal to 0 and is not equal to NULL), returns expr2; otherwise, returns expr3.
The return value of IF() can be a numeric or string value, depending on the context.
If only one of expr2 or expr3 is explicitly NULL, the return value of the IF() function is the result type of the non-NULL expression.
Examples
obclient> SELECT IF(5>6, 'T','F'), IF (5>6, 1, 0), IF(NULL, 'TRUE', 'FALSE'), IF(0, 'TRUE', 'FALSE')\G
*************************** 1. row ***************************
IF(5>6, 'T','F'): F
IF (5>6, 1, 0): 0
IF(NULL, 'TRUE', 'FALSE'): FALSE
IF(0, 'TRUE', 'FALSE'): FALSE
1 row in set
