RE: [PHP-DB] difficult count statement

From: Date: Thu, 01 May 2003 20:22:08 +0000
Subject: RE: [PHP-DB] difficult count statement
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-27474@lists.php.net to get a copy of this message
> I am running a mysql db and I would like to figure out how to count member > growth. > > For a chart I would need the number of members who have registered each > day. > > Something like this: > count (*) AS c > WHERE > regdate = '20030501' > > does not really make sense, since I would have to query the db for each > day > making it dramaticly slow. > Has anybody an idea on how to get the numbers registered each day to fead > a > graph with data? SELECT date_column, COUNT(*) AS c FROM table GROUP BY date_column Will give you a count for each date in the table. If you want it for a range, then use: SELECT date_column, COUNT(*) AS c FROM table WHERE date_column BETWEEN 20030101 AND 20030201 GROUP BY date_column Substitute your own dates, of course. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.db (#27474) next »