SQL question - problem with INTERSECT
От | Keith L. Musser |
---|---|
Тема | SQL question - problem with INTERSECT |
Дата | |
Msg-id | 001d01c042d5$c8ca1cd0$0201a8c0@quantum.idisys.com обсуждение исходный текст |
Ответы |
Re: SQL question - problem with INTERSECT
Re: SQL question - problem with INTERSECT |
Список | 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@idisys.com
В списке pgsql-general по дате отправления: