This is IF(expr1, expr2, expr3) statement
Syntax:
IF(condition,true_value,false_value)
If expr1 is TRUE (expr1 <> 0 and expr1 <> NULL) then IF() returns expr2; otherwise it returns expr3.
expr1 is evaluated as an integer value.
mysql>
mysql>
mysql> SELECT IF(1>2,2,3);
+---------------+
| IF(1>2,2,3) |
+---------------+
| 3 |
+---------------+
1 row in set (0.00 sec)
Using IF in where clause :
mysql>
mysql> select * from Employee where IF(salary > 5000,1,0) = 1;
+------+------------+-----------+------------+------------+---------+-----------+-------------+
| id | first_name | last_name | start_date | end_date | salary | city | description |
+------+------------+-----------+------------+------------+---------+-----------+-------------+
| 2 | Alison | Mathews | 1976-03-21 | 1986-02-21 | 6661.78 | Vancouver | Tester |
| 3 | James | Smith | 1978-12-12 | 1990-03-15 | 6544.78 | Vancouver | Tester |
| 7 | David | Larry | 1990-12-31 | 1998-02-12 | 7897.78 | New York | Manager |
+------+------------+-----------+------------+------------+---------+-----------+-------------+
3 rows in set (0.00 sec)