From: | Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problem with result ordering |
Date: | 2007-01-25 15:55:18 |
Message-ID: | 45B8D2E6.6040503@cox.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 01/25/07 09:45, Thorsten Körner wrote:
> 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?
What do you mean "same order"? The order that they are listed in
the IN() clause?
I doubt it. SQL is, by definition, set-oriented and the only ways
to guarantee a certain output sequence are ORDER BY and GROUP BY,
and they use collating sequences.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFFuNLmS9HxQb37XmcRAmTSAJ9mbcf8AptR4YsjdG7xBocasldfdgCdEGSz
MNjSxmx3KBP79LXRzTgQ2Qk=
=nif4
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Johnson | 2007-01-25 16:02:30 | Re: SQL Newbie Question |
Previous Message | btober | 2007-01-25 15:54:12 | Re: SQL Newbie Question |