ketanco
10-13-2008, 11:39 PM
Hello, in mysql, how do you count the non empty cells in one row? And I want to count the cells between certain columns only, say between columns 3-10. not all the columns... again, in that row only.
|
Click to See Complete Forum and Search --> : how to count non empty cells in a row ketanco 10-13-2008, 11:39 PM Hello, in mysql, how do you count the non empty cells in one row? And I want to count the cells between certain columns only, say between columns 3-10. not all the columns... again, in that row only. skywalker2208 10-13-2008, 11:47 PM Are you talking about wanting to add the values in the column together. You could do this. select (column1 + column2) from table Nedals 10-14-2008, 01:34 AM I don't think you can do that using SQL only. You will need to fetch the row array and count the empty cells in the array chazzy 10-14-2008, 06:31 AM you can use a case statement, but you need 1 case statement for each column you want to look at. NogDog 10-14-2008, 05:02 PM you can use a case statement, but you need 1 case statement for each column you want to look at. I suggested something similar using IF() over here (http://phpbuilder.com/board/showthread.php?p=10889583#post10889583). Do you think that would work? chazzy 10-14-2008, 09:49 PM I suggested something similar using IF() over here (http://phpbuilder.com/board/showthread.php?p=10889583#post10889583). Do you think that would work? Functionally, it should be equivalent. Performance wise, I can't comment which would be faster. IFNULL wouldn't apply in this case since it returns expr1 if it's not null. ketanco 10-14-2008, 10:59 PM okay it is resolved...thanks to all...i chose to pursue nedal's suggestion, since I already had the array, and consequently here is the code: //array is coming from the table by fetch array. $kkk = array(0,$q1,$q2,$q3,$q4,$q5,$q6,$q7,$q8); for($i=1; $kkk[$i]!=null; $i++) { some other code } $qtotal=$i-1; //qtotal represents the number of non empty $q in that row. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |