Re: Problem with result ordering

Поиск
Список
Период
Сортировка
Искать
От
Filip Rembiałkowski
Тема
Re: Problem with result ordering
Дата
Msg-id
92869e660701250802q74260427p20e533af8c997b1c@mail.gmail.com
Ответ на
Problem with result ordering (Thorsten Körner)
Список
Дерево обсуждения
Problem with result ordering Thorsten Körner <t.koerner@cappuccinosoft.de>
Re: Problem with result ordering "A. Kretschmer" <andreas.kretschmer@schollglas.com>
Re: Problem with result ordering Tom Lane <tgl@sss.pgh.pa.us>
Re: Problem with result ordering Tommy Gildseth <tommy@gildseth.com>
Re: Problem with result ordering Ron Johnson <ron.l.johnson@cox.net>
Re: Problem with result ordering "Filip Rembiałkowski" <filip.rembialkowski@gmail.com>
Re: Problem with result ordering Thorsten Körner <t.koerner@cappuccinosoft.de>
2007/1/25, Thorsten Körner :
> Hi,
>
> when I fire the following query:
> select m_id, m_u_id, m_title, m_rating from tablename where m_id in (26250,
> 11042, 16279, 42197, 672089);
>
> I will get the same results in the same order, as in in the next query:
> select m_id, m_u_id, m_title, m_rating from tablename where m_id in
> (11042,42197,672089,26250,16279);
>
> I wonder, how it is possible, to retrieve the results in the same order, as
> queried in the list. The listed IDs are from an application outside the
> database.
>
> Version is PostgreSQL 8.2.1
>
> Has anyone an idea, how to do this, while PostgreSQL knows nothing about
> hints, like oracle does?

obvious solution is to create temporary table like
create temp table tmp ( id serial, key integer );
then populate it with your list in order,
and then join it with your source table.

but it will require some extra coding, either in your app or in PL
set-returning function

F.
В списке pgsql-general по дате отправления
От: Inoqulath
Дата:
Сообщение: SQL Newbie Question
От: Martijn van Oosterhout
Дата:
FAQ