This sample also work in PhpMyAdmin, but not from the php code. Please advise.
**see previous post, for sample code** Thanks Rick. -john =P e p i e D e s i g n s www.pepiedesigns.com Providing Solutions That Increase Productivity Web Developement. Database. Hosting. Multimedia. On Tue, 21 Jan 2003, Rick Emery wrote: > SELECT risk_level, COUNT(*) FROM mytable GROUP BY risk_level; > > ----- Original Message ----- > From: "[-^-!-%-" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, January 21, 2003 6:06 AM > Subject: [PHP] ADV SQL Help Needed. > > > > Hello everyone, > > I need help with the following query. > > I have a table with a column named 'RISK_LEVEL'. > RISK_LEVEL can hold three values: Low, Moderate, and High. > > I need a query that counts the number of occurences of each option. > Now, I know I can do > > 'select count(risk_level) as levelCount where risk_level=low' > > for each level (low, moderate, and high). But, I was wondering if there's > anyway to merge the queries into one. > > I'm looking for something like > > "select count(risk_level='low') as lowCount, count(risk_level='moderate')as > modCount, count(risk_level='high') as highCount " > > Which will return, lowCount = 1 , modCount=3, and highCount=1, for table > with > > id | risk_level > 1 | low > 2 | moderate > 3 | moderate > 4 | high > 5 | moderate > > How do you do it? Can tha be done? > > When I run the code above, I get the same number for each record. i.e. > lowCount, modCount, and highCount all come out to 5--which is the number > of records in the table. > > Is this possible, or should I just run multiple queries? > Please help. > > > =P e p i e D e s i g n s > www.pepiedesigns.com > Providing Solutions That Increase Productivity > > Web Developement. Database. Hosting. Multimedia. > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php