SQL question - problem with INTERSECT

From: "Keith L(dot) Musser" <kmusser(at)idisys(dot)com>
To: "PGSQL-General" <pgsql-general(at)postgresql(dot)org>
Cc: "Dave Trepanier" <be164(at)yahoo(dot)com>
Subject: SQL question - problem with INTERSECT
Date: 2000-10-31 00:59:06
Message-ID: 001d01c042d5$c8ca1cd0$0201a8c0@quantum.idisys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I want to do a complicated SQL query as follows:

"(SELECT messages.msgid FROM messages, subject_index WHERE
((subject_index.word='Hello' or subject_index.word='There') and
(subject_index.msgid = messages.msgid))
GROUP BY messages.msgid HAVING count(messages.msgid)=2)
INTERSECT
(SELECT messages.msgid FROM messages, author_index WHERE
((author_index.word='Jim' or author_index.word='Jones') and
(author_index.msgid = messages.msgid))
GROUP BY messages.msgid HAVING count(messages.msgid)=2);"

The first SELECT is supposed to find messages whose subject contains
both 'Hello' and 'There'. The second SELECT is supposed to find all
messages in which the author contains both 'Jim' and 'Jones'. Each work
fine independently, but given me an error when combined with INTERSECT.

PGSQL doesn't accept the combination. It gives me this error message:
"SELECT / HAVING requires aggregates to be valid".

Can somebody explain what this means, and how I should fix it?

Keith L. Musser
Integrated Dynamics, Inc.
812-371-7777
email: kmusser(at)idisys(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ashley Clark 2000-10-31 02:36:12 Re: list configuration
Previous Message Roderick A. Anderson 2000-10-30 23:25:28 Chained table entries