Count and IF

Hi all

I'm trying to write a statment that COUNTS the number of results in a table
(below is a cut down version of the full statment)
but it's not bring back the right results

daynumberscount1 should = the COUNT of number (number is a field name)
between the 2 timestamps where
banned (another field) is = to false

daybannednumbercount1 is the same as daynumberscount1 but banned is = to
true

SELECT COUNT(IF((`timestamp` BETWEEN 1146459600 AND 1146545999) AND
banned="false",`number`,0)) as daynumberscount1, COUNT(IF((`timestamp`
BETWEEN 1146459600 AND 1146545999) AND banned="true",`number`,0)) as
daybannednumbercount1 FROM table WHERE `x` = y


I can't see where i am going wrong??

Brian
Peter Lewis [ Sa, 06 Mai 2006 20:41 ] [ ID #1304276 ]
PHP » alt.php.sql » Count and IF

Vorheriges Thema: Enforce integrity in PHP and MySQL
Nächstes Thema: pdf_open