Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 13F93475CC4 for ; Wed, 27 Nov 2002 14:34:37 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 9E45B475C5F for ; Wed, 27 Nov 2002 14:34:36 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 8A98043A629; Wed, 27 Nov 2002 14:34:36 -0500 (EST) From: "Arcadius A." X-Newsgroups: comp.databases.postgresql.sql Subject: Re: SQL query help! Date: Wed, 27 Nov 2002 20:34:32 +0100 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 44 Message-ID: References: <3DE498E4.2050002@ualg.pt> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 To: pgsql-sql@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/428 X-Sequence-Number: 10570 Hello! "Luis Sousa" 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.