From: | Tim Landscheidt <tim(at)tim-landscheidt(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to force select to return exactly one row |
Date: | 2010-06-22 00:20:35 |
Message-ID: | m3bpb33oks.fsf@passepartout.tim-landscheidt.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Brett Mc Bride <brett(dot)mcbride(at)deakin(dot)edu(dot)au> wrote:
> My understanding of UNION ALL is that it won't sort the rows...?
> [...]
It doesn't, but that's not promised for every data set, ev-
ery PostgreSQL version, every phase of the moon. To quote
<URI:http://www.postgresql.org/docs/8.4/interactive/queries-union.html>:
| UNION effectively appends the result of query2 to the result
| of query1 (although there is no guarantee that this is the
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| order in which the rows are actually returned). Furthermore,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| it eliminates duplicate rows from its result, in the same
| way as DISTINCT, unless UNION ALL is used.
SQL deals with (unordered) sets, and therefore any use of
"LIMIT" without "ORDER BY" indicates a bug waiting to bite
you when you least expect it.
Tim
From | Date | Subject | |
---|---|---|---|
Next Message | Dann Corbit | 2010-06-22 02:20:24 | Re: Trying to install ODBC driver on Windows XP notebook |
Previous Message | Brett Mc Bride | 2010-06-21 23:49:13 | Re: How to force select to return exactly one row |