X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9F933529EA for ; Wed, 29 Jun 2005 08:19:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29231-03 for ; Wed, 29 Jun 2005 11:19:09 +0000 (GMT) Received: from hotmail.com (bay103-dav2.bay103.hotmail.com [65.54.174.74]) by svr1.postgresql.org (Postfix) with ESMTP id 6D37F529E4 for ; Wed, 29 Jun 2005 08:19:06 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 29 Jun 2005 04:19:09 -0700 Message-ID: Received: from 65.54.174.204 by BAY103-DAV2.phx.gbl with DAV; Wed, 29 Jun 2005 11:19:09 +0000 X-Originating-IP: [65.54.174.204] X-Originating-Email: [russellsimpkins@hotmail.com] X-Sender: russellsimpkins@hotmail.com From: "Russell Simpkins" To: Subject: Re: ORDER records based on parameters in IN clause Date: Wed, 29 Jun 2005 07:19:22 -0400 Message-ID: <000b01c57c9c$66589170$6401a8c0@simpkinshome1> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal In-Reply-To: <937a483c3b3a9809ec978a24b9d9af76@biglumber.com> X-OriginalArrivalTime: 29 Jun 2005 11:19:09.0781 (UTC) FILETIME=[5ED6E050:01C57C9C] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.362 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, MSGID_FROM_MTA_HEADER X-Spam-Level: * X-Archive-Number: 200506/348 X-Sequence-Number: 21949 >> when I say >> select * from table where id IN (2003,1342,799, 1450) >> I would like the records to be ordered as 2003, 1342, 799, 1450. >Just say: >select * from table where id IN (2003,1342,799, 1450) ORDER BY id; >If that doesn't work, you will have to be more specific and send us the exact query. Order by id will not do what you want, but this should. Select * from table where id = 2003; Union all Select * from table where id = 1342; Union all Select * from table where id = 799; Union all Select * from table where id = 1450;