>> I've got query like this:

 >> "select count(ID) from TABLE where (TABLE.A + TABLE.B + TABLE.C +
 >> TABLE.D) > 0"

 >> A,B,C,D are decimal values.

 >> The problem is, I think, with NULL columns. Often B,C and D don't
 >> have decimal value, but NULL.
 >> I thought, that this should be counted like zero. Am I wrong ?

 RB> NULL is not the same as zero.

 RB> If any of the field values are NULL, the result of the expression is
 RB> NULL.

Hey guys Is this so hard to help people instead of killing them ?

Use IFNULL(null_field, 0)

And your query will be like:
select count(ID) from TABLE where (IFNULL(TABLE.A, 0) + IFNULL(TABLE.B, 0) + 
IFNULL(TABLE.C, 0)
+  IFNULL(TABLE.D,0)) > 0

And I advice you - RTFM.

---
Yours sincerely, Ivan Latysh.
[EMAIL PROTECTED]
http://ivan.yourmail.com


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to