Re: SQL query help!

From: "Arcadius A(dot)" <ahouans(at)sh(dot)cvut(dot)cz>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: SQL query help!
Date: 2002-11-27 19:34:32
Message-ID: as36oc$2ss7$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-sql

Hello!

"Luis Sousa" <llsousa(at)ualg(dot)pt> wrote in message
news:3DE498E4(dot)2050002(at)ualg(dot)pt(dot)(dot)(dot)
> This is a cryptographically signed message in MIME format.
>
> --------------ms080209060900030807050408
> Content-Type: text/plain; charset=us-ascii; format=flowed
> Content-Transfer-Encoding: 7bit
>
> Tell me what did you try with limit and group by.
> Where's IN, why don't you use EXISTS instead. It runs much master !
>

Thanks for the reply!
Alright, I'll use EXISTS instead of IN .... I didn't know that EXISTS is
faster.....

About my query, I have tried :

"
SELECT * FROM entry where isapproved='y' AND EXISTS (SELECT id
FROM subcategory WHERE catid='2') ORDER BY subcatid DESC LIMIT 5;
";
This will return only 5 rows....

But when I add the GROUP BY, then I got error
"
SELECT * FROM entry where isapproved='y' AND EXISTS (SELECT id
FROM subcategory WHERE catid='2') ORDER BY subcatid DESC LIMIT 5 GROUP BY
subcatid;
"

: ERROR: parser: parse error at or near "GROUP"

Thanks.....

Arcadius.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-11-27 19:42:10 Re: fatal error in database
Previous Message Tom Lane 2002-11-27 19:27:14 Re: How was my PG compiled

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2002-11-27 19:44:02 Re: Request from eWeek for 7.3 comments
Previous Message Ken Hirsch 2002-11-27 19:22:55 Re: nested transactions

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Childs 2002-11-27 20:04:40 Re: Question on SQL and pg_-tables
Previous Message Nathan Young 2002-11-27 17:37:07 Re: join question