Here i am going to show how to display custom Text when there are NULL columns in SQL and MySql as follows...
I had a table name as Childs with the following values. and the query to show values is select Query
select * from Child
 
 
I had a table name as Childs with the following values. and the query to show values is select Query
select * from Child
| 
Childid | 
Childname | 
Adultid | 
| 
1 | 
ramu 
       | 
3 | 
| 
2 | 
venki 
      | 
3 | 
| 
3 | 
shyam 
      | 
4 | 
| 
4 | 
somu 
       | 
5 | 
| 
5 | 
kiran 
      | 
8 | 
| 
6 | 
phani 
      | 
7 | 
| 
7 | 
kavya 
      | 
1 | 
| 
8 | 
vanju 
      | 
1 | 
| 
9 | 
keerthi    | 
6 | 
| 
10 | 
malathi    | 
null  | 
| 
11 | 
venu 
       | 
null  | 
| 
12 | 
kishore    | 
6 | 
So now I want to display these null values as 0 / any text as we like.
In my case 0 for whom parents are not there.
In my case 0 for whom parents are not there.
To do so the Query is as follows
select childid,childname,ISNULL(adultid,'0') as adultid from Child
And the Results are :-
| 
Childid | 
Childname | 
Adultid | 
| 
1 | 
ramu 
       | 
3 | 
| 
2 | 
venki 
      | 
3 | 
| 
3 | 
shyam 
      | 
4 | 
| 
4 | 
somu 
       | 
5 | 
| 
5 | 
kiran 
      | 
8 | 
| 
6 | 
phani 
      | 
7 | 
| 
7 | 
kavya 
      | 
1 | 
| 
8 | 
vanju 
      | 
1 | 
| 
9 | 
keerthi    | 
6 | 
| 
10 | 
malathi    | 
0 | 
| 
11 | 
venu 
       | 
0 | 
| 
12 | 
kishore    | 
6 | 
 
 
No comments:
Post a Comment