Received: from server.solartec.cz (server.solartec.cz [212.20.66.5]) by postgresql.org (Postfix) with ESMTP id A8418475897 for ; Thu, 18 Apr 2002 04:05:52 -0400 (EDT) Received: from localhost.localdomain (IDENT:root@athlon.solartek.in [10.10.1.95]) by server.solartec.cz (8.11.0/8.11.0) with ESMTP id g3I85qt02151 for ; Thu, 18 Apr 2002 10:05:53 +0200 Received: from solartec.cz (IDENT:tycho@spravce.solartek.in [10.10.1.98]) by localhost.localdomain (8.9.3/8.8.7) with ESMTP id KAA21201 for ; Thu, 18 Apr 2002 10:05:52 +0200 Message-ID: <3CBE7E60.40003@solartec.cz> Date: Thu, 18 Apr 2002 10:05:52 +0200 From: Petr Bravenec User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Gecko/20020310 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: SQL question.. References: <006d01c1e630$0b8356a0$14818b0a@ctcd.cc.tx.us> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Archive-Number: 200204/788 X-Sequence-Number: 23503 It looks like an impossible thing in SQL. The only way to achieve this may be an temporary table with added sorting information: create temporary table tpmsort (linenum serial, id int4); insert into tmpsort (id) values (4); insert into tmpsort (id) values (3); insert into tmpsort (id) values (1); insert into tmpsort (id) values (2); .... in the order you requested and then select * from table, tmpsort where table.id = tmpsort.id order by tmpsort.linenum; Petr Bravenec Alexis Maldonado wrote: > > > I have a query list of IDs ( 4,3,1,2,12,5,6,8,7,9,11) > > > > I want to build a query that gets those IDs in the exact same order > but when i do > > > > Select * From Table > > Where ID IN ( 4,3,1,2,12,5,6,8,7,9,11) > > > > It gets all the IDs in random order.. > > > > how can i get them in the order listed? >