hi i have a query where i have count and sum of the columns.
but if data is not in column its showing null value
query are like
$sql=mysql_query("SELECT count(*), sum(`Classrooms`),sum(`Male_teaching`),sum(`Female_teaching`),sum(`Total`),sum(boys1+ girls1+boys2+girls2+boys3+girls3+boys4+girls4+boys5+girls5+boys6+girls6+boys7+girls7+boys8) as st FROM `dies_tb` where School_desc='$j' and blockcode='$pid' and Clustercode='$cid'");
count(*) sum(`Classrooms`) sum(`Male_teaching`) sum(`Female_teaching`) sum(`Total`) st
0 NULL NULL NULL NULL NULL
when i see the value in table its show nothing ,i want to show 0 value if value is not there.............
Pl Help
Thanks
problem with My sql query
Moderator: General Moderators
-
manojsemwal1
- Forum Contributor
- Posts: 217
- Joined: Mon Jun 29, 2009 4:13 am
- Location: India
-
litebearer
- Forum Contributor
- Posts: 194
- Joined: Sat Mar 27, 2004 5:54 am
Re: problem with My sql query
Perhaps psudeo code...
if variable <1 echo "0" else echo variable
if variable <1 echo "0" else echo variable
Re: problem with My sql query
MySQL Manual: COALESCE()