Re: SQL query help! - Mailing list pgsql-sql

From Arcadius A.
Subject Re: SQL query help!
Date
Msg-id as36oc$2ss7$1@news.hub.org
Whole thread Raw
In response to Re: SQL query help!  (Luis Sousa <llsousa@ualg.pt>)
List pgsql-sql
Hello!

"Luis Sousa" <llsousa@ualg.pt> wrote in message
news:3DE498E4.2050002@ualg.pt...
> 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.





pgsql-sql by date:

Previous
From: Christoph Haller
Date:
Subject: Re: retrieving specific info. from one column and locating it in another
Next
From: Rudi Starcevic
Date:
Subject: Analyze + Index