IF « Control Flow Functions « MySQL Tutorial

18.3.2.Using string comparison function with IF
18.3.3.Using IF with float point value
18.3.4.Use IF with data in a table
18.3.5.Using IF in where clause
18.3.6.Using IF() function to compare numbers
18.3.7.A number can also be returned from IF() function
18.3.8.Use and IF() and COUNT() to give us a total as COUNT() ignores NULL values