Page 1 of 1

problem with My sql query

Posted: Sat Feb 19, 2011 1:31 am
by manojsemwal1
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

Re: problem with My sql query

Posted: Sat Feb 19, 2011 7:20 am
by litebearer
Perhaps psudeo code...
if variable <1 echo "0" else echo variable

Re: problem with My sql query

Posted: Sat Feb 19, 2011 12:23 pm
by McInfo
MySQL Manual: COALESCE()