Skip site navigation (1) Skip section navigation (2)

Query Problem

From: David Costa <geeks(at)dotgeek(dot)org>
To: pgsql-php(at)postgresql(dot)org
Subject: Query Problem
Date: 2004-03-17 20:21:56
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-php
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!

David Costa, PHP-PostgreSQL Advocacy team
david at postgresql ddoot org                 gurugeek att php dot net
$dsn = 'pgsql://world:most_advanced(at)localhost/open_source_database';


pgsql-php by date

Next:From: Ron St-PierreDate: 2004-03-17 21:17:02
Subject: Re: Query Problem
Previous:From: scott.marloweDate: 2004-03-17 16:22:05
Subject: Re: FUNCTIONS

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group