how to count non empty cells in a row
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.
Are you talking about wanting to add the values in the column together. You could do this.
select (column1 + column2) from table
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
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. Do you think that would work?
Originally Posted by chazzy
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.
Originally Posted by NogDog
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 represents the number of non empty $q in that row.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread