Re: please help me in this query ( add condition to count())
Posted by: Jack Gates
Date: February 21, 2010 02:33PM

Give this a try:

SELECT c.catname, SUM(p.active = 1) AS numposts
FROM categories AS c
LEFT JOIN posts AS p ON c.catid = p.catid
GROUP BY c.catname


(Recommend you switch to 'General' or 'Newbie' forum.) I have a site that needs a database, since it deals with Dominican Republic villas ( houses, real estate ) and we`re having some issues with adding new listings, too much work doing html for each one. the url is http://www.goldenkeymanagement.com and as you can see everything is done in pure html, there is no CMS on it. Poor webmaster :)
If anyone knows how to do this, drop me a note.

Options: ReplyQuote


Subject
Written By
Posted
Re: please help me in this query ( add condition to count())
February 21, 2010 02:33PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.