From: Petr Bravenec <pbravenec@solartec.cz>
To: pgsql-general@postgresql.org
Subject: Re: SQL question..
Date: Thu, 18 Apr 2002 10:05:52 +0200
Message-ID: <3CBE7E60.40003@solartec.cz> (raw)
References: <006d01c1e630$0b8356a0$14818b0a@ctcd.cc.tx.us>
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?
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: pbravenec@solartec.cz
Subject: Re: SQL question..
In-Reply-To: <3CBE7E60.40003@solartec.cz>
References: <006d01c1e630$0b8356a0$14818b0a@ctcd.cc.tx.us> <3CBE7E60.40003@solartec.cz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox