Query construction

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Query construction
Groups: php.db 
Request: Send a blank email to php-db+get-11590@lists.php.net to get a copy of this message
Hi there people: I have a MySQL table consisting of category names among other things. I would like to be able to construct a query that tells me the number of times a unique category name occurs in the table: //Table 'posts' from command-line mysql> explain posts; +----------+-------------+------+-----+------------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------+-------------+------+-----+------------+----------------+ | id | tinyint(3) | | PRI | 0 | auto_increment | | category | varchar(25) | | | | | | user | varchar(12) | | | | | | dateFrom | date | | | 0000-00-00 | | | dateTo | date | | | 0000-00-00 | | | title | varchar(25) | | | | | | body | text | | | NULL | | +----------+-------------+------+-----+------------+----------------+ 7 rows in set (0.00 sec) //Table 'posts' in phpMyAdmin tab id category user dateFrom dateTo title body 3 some stuff maurice 2001-09-23 2001-11-05 Maurcie's post this is Maurice's test 4 russ category russmichell 2001-08-17 2001-08-27 Russ is theone this is another test 9 russ category russmichell 2001-08-16 2001-08-19 Begon by Monday! This entry should dissapear 10 russ category russmichell 2001-08-16 2001-09-04 testing This is another test! For example I would like to know how many posts there are in the category 'russ category' (Should tell me there are 3 and only 1 for 'some stuff' ... Can anyone help me toward a nice SQL query that would to this for me!? Cheers all. Russ #-------------------------------------------------------# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam e: r.j.michell@apu.ac.uk w: www.apu.ac.uk/webteam t: +44 (0)1223 363271 x 2331 www.theruss.com #-------------------------------------------------------#

« previous php.db (#11590) next »