[MySQL] IF Syntax
IF(expr1,expr2,expr3)
If expr1
is TRUE
(
and expr1
<> 0
) then expr1
<> NULLIF()
returns expr2
; otherwise it returns expr3
. IF()
returns a numeric or string value, depending on the context in which it is used.
mysql> SELECT IF(1>2,2,3); -> 3 mysql> SELECT IF(1<2,'yes','no'); -> 'yes' mysql> SELECT IF(STRCMP('test','test1'),'no','yes'); -> 'no'
Read Online: http://dev.mysql.com/doc/refman/5.7/en/control-flow-functions.html
http://dev.mysql.com/doc/refman/5.7/en/if.html