| Bug #10032 | Unexpected syntax error in UNION statement with ORDER BY | ||
|---|---|---|---|
| Submitted: | 20 Apr 2005 17:04 | Modified: | 1 Jun 2005 5:15 |
| Reporter: | Victoria Reznichenko | ||
| Status: | Closed | ||
| Category: | Server: Optimizer | Severity: | S3 (Non-critical) |
| Version: | 4.1.12 | OS: | Linux (linux) |
| Assigned to: | Sinisa Milivojevic | Target Version: | |
[20 Apr 2005 17:04]
Victoria Reznichenko
[21 Apr 2005 9:19]
Alexander Keremidarski
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: This is well documented behaviour of UNION in MySQL http://dev.mysql.com/doc/mysql/en/union.html 13.1.7.2. UNION Syntax If you want to use an ORDER BY or LIMIT clause to sort or limit the entire UNION result, parenthesize the individual SELECT statements and place the ORDER BY or LIMIT after the last one. The following example uses both clauses: (SELECT a FROM tbl_name WHERE a=10 AND B=1) UNION (SELECT a FROM tbl_name WHERE a=11 AND B=2) ORDER BY a LIMIT 10;
[26 Apr 2005 20:00]
Sinisa Milivojevic
Committing now ...
[26 Apr 2005 20:13]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/24337
[1 Jun 2005 5:15]
Paul DuBois
Noted in 4.1.12 changelog.
