pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedQuery Problem
2+ messages / 2 participants
[nested] [flat]
* Query Problem
@ 2004-03-17 20:21 David Costa <geeks@dotgeek.org>
2004-03-17 21:17 ` Re: Query Problem Ron St-Pierre <rstpierre@syscor.com>
0 siblings, 1 reply; 2+ messages in thread
From: David Costa @ 2004-03-17 20:21 UTC (permalink / raw)
To: 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!
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';
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Query Problem
2004-03-17 20:21 Query Problem David Costa <geeks@dotgeek.org>
@ 2004-03-17 21:17 ` Ron St-Pierre <rstpierre@syscor.com>
0 siblings, 0 replies; 2+ messages in thread
From: Ron St-Pierre @ 2004-03-17 21:17 UTC (permalink / raw)
To: David Costa <geeks@dotgeek.org>; pgsql-php
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;
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-03-17 21:17 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-03-17 20:21 Query Problem David Costa <geeks@dotgeek.org>
2004-03-17 21:17 ` Ron St-Pierre <rstpierre@syscor.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox