Re: SQL question..

Поиск
Список
Период
Сортировка
От Petr Bravenec
Тема Re: SQL question..
Дата
Msg-id 3CBE7E60.40003@solartec.cz
обсуждение исходный текст
Ответ на SQL question..  ("Alexis Maldonado" <amaldona@ctcd.cc.tx.us>)
Список pgsql-general
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?
>



В списке pgsql-general по дате отправления:

Предыдущее
От: Lee Kindness
Дата:
Сообщение: determining database size
Следующее
От: Egon Sommer
Дата:
Сообщение: Performance of column order