UNION & LIMIT & ORDER BY
UNION & LIMIT & ORDER BY
От:
Emmanuel Engelhart <emmanuel@engelhart.org>
Дата:
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
Re: UNION & LIMIT & ORDER BY
От:
Guillaume LELARGE <gleu@wanadoo.fr>
Дата:
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 .