Re: sorted result - Mailing list pgsql-novice

From Einar Karttunen
Subject Re: sorted result
Date
Msg-id 20011025141930.A24210@cs.helsinki.fi
Whole thread Raw
In response to sorted result  ("Al-Haddad, Mohammad J" <mjalha@essex.ac.uk>)
List pgsql-novice
On Thu, Oct 25, 2001 at 11:58:39AM +0100, Al-Haddad, Mohammad J wrote:
> hi there,
> if  I have a table T1 with primary key P. and attributes A1,A2 and A3
> and I have this query:
> select * form T1 where the P = 123;
>
> do I get the intermediate relation result sorted based on the primary
> key?
>
> what about if the query somthing like this:
> select A1 from T1 where A2 = 456
>
> do I get the intermediate result sorted by the primary key
>
No, all results are returned in a pseudo-random order.
If you wish that the resultset is sorted use the ORDER BY-clause.

SELECT * FROM T1 WHERE A2=456;
pseudo-random order.

SELECT * FROM T1 WHERE A2=456 ORDER BY P;
sorted.

- Einar Karttunen

pgsql-novice by date:

Previous
From: "Al-Haddad, Mohammad J"
Date:
Subject: sorted result
Next
From: "Joshua b. Jore"
Date:
Subject: undo delete w/ transaction?