Re: ORDER records based on parameters in IN clause - Mailing list pgsql-sql

From Russell Simpkins
Subject Re: ORDER records based on parameters in IN clause
Date
Msg-id BAY103-DAV2F286C12D1CD00118F13AB5E00@phx.gbl
Whole thread Raw
In response to Re: ORDER records based on parameters in IN clause  ("Greg Sabino Mullane" <greg@turnstep.com>)
List pgsql-sql
>> when I say
>> select * from table where id IN (2003,1342,799, 1450)
>> I would like the records to be ordered as 2003, 1342, 799, 1450.
>Just say:
>select * from table where id IN (2003,1342,799, 1450) ORDER BY id;
>If that doesn't work, you will have to be more specific and send us the
exact query.

Order by id will not do what you want, but this should.
Select * from table where id = 2003;
Union all
Select * from table where id = 1342;
Union all
Select * from table where id = 799;
Union all
Select * from table where id = 1450;


pgsql-sql by date:

Previous
From: Dawid Kuroczko
Date:
Subject: Re: ENUM like data type
Next
From: Dawid Kuroczko
Date:
Subject: Re: ORDER records based on parameters in IN clause