Skip site navigation (1) Skip section navigation (2)

Order by provided IDs?

From: Mark Kelly <pgsql(at)wastedtimes(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Order by provided IDs?
Date: 2010-07-14 18:03:25
Message-ID: 201007141903.25271.pgsql@wastedtimes.net (view raw or flat)
Thread:
Lists: pgsql-novice
Hi.

If my query is:

SELECT art_id, art_headline, art_date 
FROM article 
WHERE art_id IN (357, 344, 120, 258, 369, 195, 343, 370);

can I ask Postgres to return the rows in the order of the IDs in the IN 
clause? They are in a specific order defined outside the database.

Thanks,

Mark

Responses

pgsql-novice by date

Next:From: Thomas KellererDate: 2010-07-14 18:22:44
Subject: Re: Order by provided IDs?
Previous:From: DMan65Date: 2010-07-13 23:25:59
Subject: Need help doing a CSV import

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group