Handle null values in MySQL query itself instead of handling them in jsp pages.
Syntax:
Select IFNULL (exp1,exp2) , IFNULL (exp1,exp2) from tableName
IFNULL return exp1 if it is not null
Else
If exp1 is null then returns exp2
Example 1:
In Interface it looks like this:

Select IFNULL(Name,’ Not Available ’),IFNULL(Address,’Not Available ’),IFNULL(emailed,’Not Available’) from tableName
Result:
In Interface it looks like this:

Example 2:
Select IFNULL(Name,’ ’),IFNULL(Address,’ ’),IFNULL(emailed,’ ’) from tableName
Result:
In Interface it looks like this:
Syntax:
Select IFNULL (exp1,exp2) , IFNULL (exp1,exp2) from tableName
IFNULL return exp1 if it is not null
Else
If exp1 is null then returns exp2
Example 1:
| Name | Address | emailID |
| Jagadish | Bangalore | null |
In Interface it looks like this:
Select IFNULL(Name,’ Not Available ’),IFNULL(Address,’Not Available ’),IFNULL(emailed,’Not Available’) from tableName
Result:
| Telephone1 | Telephone2 | Fax |
| 9903124243 | Not Available | Not Available |
In Interface it looks like this:
Example 2:
Select IFNULL(Name,’ ’),IFNULL(Address,’ ’),IFNULL(emailed,’ ’) from tableName
Result:
| Telephoen1 | Telephone2 | Fax |
| 9903124243 |
In Interface it looks like this:
Comments