X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 74074D1D2F7 for ; Wed, 17 Mar 2004 21:16:14 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 84658-01 for ; Wed, 17 Mar 2004 17:16:11 -0400 (AST) Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net [24.108.208.253]) by svr1.postgresql.org (Postfix) with ESMTP id B45C0D1B4D3 for ; Wed, 17 Mar 2004 17:16:08 -0400 (AST) Received: from syscor.com (strider.syscor.priv [192.168.1.3]) by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i2HLGAXR013711; Wed, 17 Mar 2004 13:16:10 -0800 Message-ID: <4058C04E.5010107@syscor.com> Date: Wed, 17 Mar 2004 13:17:02 -0800 From: Ron St-Pierre User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 To: David Costa , pgsql-php@postgresql.org Subject: Re: Query Problem References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200403/39 X-Sequence-Number: 2638 David Costa wrote: > Hi There !! > My turn to ask for some help ;) > > a friend of mine has a problem with this query: > > SELECT zblog_category.catname, zblog_entry.entry_id, > zblog_entry.entrytext, zblog_entry.entrytitle, > zblog_entry.timestamp_creation, zblog_user.username, > COUNT(zblog_comment.comment_id) AS comment_amount FROM zblog_comment > RIGHT JOIN (zblog_user INNER JOIN (zblog_entry INNER JOIN > zblog_category ON (zblog_category.cat_id = zblog_entry.id_cat)) ON > (zblog_entry.id_user = zblog_user.user_id)) ON (zblog_comment.id_entry > = zblog_entry.entry_id) WHERE zblog_comment.id_entry = > zblog_entry.entry_id AND zblog_category.cat_id = zblog_entry.id_cat > AND zblog_user.user_id = zblog_entry.id_user AND > zblog_entry.timestamp_creation >= 1 AND zblog_entry.timestamp_creation > < 999999999999 GROUP BY zblog_entry.entry_id ORDER BY > zblog_entry.timestamp_creation DESC > > The error we are getting is this > > ERROR: column "zblog_category.catname" must appear in the GROUP BY > clause or be used in an aggregate function > > any idea? we kept trying for hours to no avail *sigh* :'( > > thanks in advance for your time and attention! > > > Regards, > David Costa, PHP-PostgreSQL Advocacy team http://dotgeek.org > david at postgresql ddoot org gurugeek att php dot net > $dsn = 'pgsql://world:most_advanced@localhost/open_source_database'; > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster When using GROUP BY for one or more columns, each column must be listed in GROUP BY or used in an aggregate function. eg: SELECT kind, SUM(len) AS total FROM films GROUP BY kind; - or - SELECT kind, len FROM films GROUP BY kind, len;