Using IF() function to compare numbers : IF « Control Flow Functions « MySQL Tutorial






mysql>
mysql> SELECT IF(15>10,'Yup','Nope');
+------------------------+
| IF(15>10,'Yup','Nope') |
+------------------------+
| Yup                    |
+------------------------+
1 row in set (0.02 sec)

mysql>
mysql> SELECT IF(5>10,'Yup','Nope');
+-----------------------+
| IF(5>10,'Yup','Nope') |
+-----------------------+
| Nope                  |
+-----------------------+
1 row in set (0.00 sec)

mysql>








18.3.IF
18.3.1.IF(expr1,expr2,expr3)
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