> 
> Hi all,
> 
> I'd like to make a single query that returns a number of rows using a
> 'WHERE id IN (<list-of-ids>)' condition, but I'd like the rows to be
> returned in the order in which the ids are given in the list.
> 
> Is this possible?
> 

Depending on how many IDs you have in your list, you can accomplish this
with a CASE statement:

SELECT *
FROM MYTABLE
WHERE id IN (6, 9, 3)
ORDER BY CASE id 
WHEN 6 then 1
WHEN 9 then 2
WHEN 3 then 3 END










-- 
Sent via pgsql-general mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to