pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedUNION & LIMIT & ORDER BY
2+ messages / 2 participants
[nested] [flat]
* UNION & LIMIT & ORDER BY
@ 2003-06-14 17:01 Emmanuel Engelhart <emmanuel@engelhart.org>
0 siblings, 1 reply; 2+ messages in thread
From: Emmanuel Engelhart @ 2003-06-14 17:01 UTC (permalink / raw)
To: pgsql-sql
Hi
Why this query doesn't work ?
<<
SELECT
'1' AS id
FROM
users
ORDER BY id
LIMIT 1
UNION
SELECT
'2' AS id
FROM
users
>>
And this one work ?
<<
SELECT
'1' AS id
FROM
users
UNION
SELECT
'2' AS id
FROM
users
ORDER BY id
LIMIT 1
>>
--
-------------------------------------------------------------------------
| Dans le cours d'un long gouvernement, on va au mal par une pente |
| insensible, et ne remonte au bien que par un effort. |
| Montesquieu, "de l'esprit des lois" livre V/VII |
-------------------------------------------------------------------------
Emmanuel Engelhart alias Kelson | ICQ UIN : 53388731 | TEL 01.58.46.04.79
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: UNION & LIMIT & ORDER BY
@ 2003-06-16 19:37 Guillaume LELARGE <gleu@wanadoo.fr>
parent: Emmanuel Engelhart <emmanuel@engelhart.org>
0 siblings, 0 replies; 2+ messages in thread
From: Guillaume LELARGE @ 2003-06-16 19:37 UTC (permalink / raw)
To: emmanuel@engelhart.org; +Cc: pgsql-sql
Hi,
Le Samedi 14 Juin 2003 17:01, Emmanuel Engelhart a écrit :
> [...]
Taken from the postgresql manual
(http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=sql-select.html#SQL-UNION):
ORDER BY and LIMIT can be attached to a sub-expression if it is enclosed in
parentheses. Without parentheses, these clauses will be taken to apply to the
result of the UNION, not to its right-hand input expression.
Regards.
--
Guillaume <!-- http://absfr.tuxfamily.org/ -->.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-06-16 19:37 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-14 17:01 UNION & LIMIT & ORDER BY Emmanuel Engelhart <emmanuel@engelhart.org>
2003-06-16 19:37 ` Guillaume LELARGE <gleu@wanadoo.fr>
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