From: Michael Glaesemann <grzm@seespotcode.net>
To: Christian Paul Cosinas <cpc@cybees.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: ORDER BY question
Date: Thu, 11 May 2006 12:55:19 +0900
Message-ID: <E44B1B2B-C525-44E3-8FF0-1975D62A0FBB@seespotcode.net> (raw)
In-Reply-To: <018701c674f2$756133d0$1e21100a@ghwk02002147>
References: <018701c674f2$756133d0$1e21100a@ghwk02002147>
On May 11, 2006, at 21:00 , Christian Paul Cosinas wrote:
> For example I have a table like this
>
> ID Name
> 1 A
> 1 B
> 2 C
> 2 D
>
> And I have a Query like this:
> SELECT * FROM table ORDER BY ID.
>
> Would my result always give me the same order or is there may be a
> possible
> different result?
It may give you a different result: if the order is not explicitly
specified by the ORDER BY clause, you are not guaranteed to get the
rows back in any particular order. So for cases where you may not be
ordering on a unique column (such as above), you may want to do
something like:
SELECT *
FROM table
ORDER BY "ID", "Name";
Hope this helps.
Michael Glaesemann
grzm seespotcode net
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: grzm@seespotcode.net, cpc@cybees.com
Subject: Re: ORDER BY question
In-Reply-To: <E44B1B2B-C525-44E3-8FF0-1975D62A0FBB@seespotcode.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox