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 9859F5280C for ; Thu, 30 Jun 2005 04:35:11 -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 29008-05 for ; Thu, 30 Jun 2005 07:35:02 +0000 (GMT) Received: from s001.mxhosting.nl (unknown [213.206.92.11]) by svr1.postgresql.org (Postfix) with ESMTP id 1579852806 for ; Thu, 30 Jun 2005 04:34:58 -0300 (ADT) Received: from pinbizz.xs4all.nl ([82.92.94.47] helo=[192.168.11.224]) by s001.mxhosting.nl with asmtp (Exim 4.40 (FreeBSD)) id 1Dnt0M-0008tk-04 for pgsql-sql@postgresql.org; Thu, 30 Jun 2005 08:58:34 +0200 Message-ID: <42C3A0A3.40101@dltmedia.nl> Date: Thu, 30 Jun 2005 09:34:59 +0200 From: "M.D.G. Lange" User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: ORDER records based on parameters in IN clause References: <1120057638.8208.117.camel@state.g2switchworks.com> In-Reply-To: <1120057638.8208.117.camel@state.g2switchworks.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - s001.mxhosting.nl X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [26 6] X-AntiAbuse: Sender Address Domain - dltmedia.nl X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/367 X-Sequence-Number: 21968 Another option would be: SELECT * FROM table WHERE id=2003 OR id=1342 OR id=799 OR id=1450; This should give you the results in the right order... - Michiel Scott Marlowe wrote: >On Wed, 2005-06-29 at 09:22, Russell Simpkins wrote: > > >>fair enough. but a simple order by id would never work. >> >> >> > >Try this: > >select *, > case > when id=2003 then 1 > when id=1342 then 2 > when id=799 then 3 > when id=1450 then 4 > end as ob >from > tablename >where > id in (2003,1342,799,1450) >order by > ob; > >---------------------------(end of broadcast)--------------------------- >TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > > > > >