Forum Moderators: coopster

Message Too Old, No Replies

Select count but exclude counting empty fields?

         

maccas

12:32 am on Jun 6, 2005 (gmt 0)

10+ Year Member



Hi, any pointers on how I can exclude counting any instances where a field is empty? i.e I have

$sql = 'SELECT count(reviewid) as num_times FROM reviews WHERE reviewid =' . $id;

I use this to get an average. But some times the average field is empty. So in the above I want to exclude it counting where the average is blank.

MattAU

2:05 am on Jun 6, 2005 (gmt 0)

10+ Year Member



I'm not sure I understand exactly what you mean, but try adding "AND field!= ''" or maybe "AND field IS NOT NULL" to the end of the query.

My first post :)

coopster

4:10 am on Jun 6, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Sounds like a plan to me. Give it a shot, maccas.

And welcome to WebmasterWorld, MattAU.