Re: ORDER records based on parameters in IN clause

Поиск
Список
Период
Сортировка
От M.D.G. Lange
Тема Re: ORDER records based on parameters in IN clause
Дата
Msg-id 42C3A0A3.40101@dltmedia.nl
обсуждение исходный текст
Ответ на Re: ORDER records based on parameters in IN clause  (Scott Marlowe <smarlowe@g2switchworks.com>)
Ответы Re: ORDER records based on parameters in IN clause
Re: ORDER records based on parameters in IN clause
Список pgsql-sql
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
>
>
>
>  
>


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

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: Error saving image to PostgresSQL 8.x database
Следующее
От: Dawid Kuroczko
Дата:
Сообщение: Re: ORDER records based on parameters in IN clause