The MYSQL generally includes 3 pre-made functions that are considered to flow functions. These pre-made fucntions are explained in sessions below.

IF(exp1, exp2, exp3)

The function IF() accepts 3 arguments, and is used to evaluate an expression (exp1 in the title); if the expression is 'TRUE', the function will return exp2, otherwise returns exp3. The example below displays ZipCode of the tblpatients. If the result is NULL, it displays as "N/A".

SELECT IF(ZipCode IS NULL, "N/A", ZipCode) FROM `tblpatients`;

IFNULL(exp1, exp2)

The function IFNULL() checks if exp1 variable is NULL. If it is not, the statement returns exp1, else it returns exp2. The example below should return phone number of customers. For rows which has "OfficePhone" as NULL, it returns the "HomePhone".

SELECT IFNULL(`OfficePhone`,`HomePhone`) FROM `tblCustomers`;

NULLIF(exp1, exp2)

The function NULLIF() returns NULL if exp1=exp2 is TRUE. However if the result is not equal, the statement returns exp1. The example below displays Female students in the list with male students where Sex is written as 0.

SELECT NULLIF(IF(Sex="F","F","0"),"M") AS Female FROM `tblstudents`;