Bug #28431 | UNIOIN with ORDER BY returns error | ||
---|---|---|---|
Submitted: | 15 May 2007 4:18 | Modified: | 15 May 2007 5:49 |
Reporter: | Jared S (Silver Quality Contributor) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
Version: | 5.0.40 | OS: | Windows (Vista) |
Assigned to: | CPU Architecture: | Any | |
Tags: | order by, qc, query, UNION |
[15 May 2007 4:18]
Jared S
[15 May 2007 5:49]
Valeriy Kravchuk
Thank you for a problem report. Sorry, but this is not a bug. You have to use: (select ... order by ...) UNION (select ... order by ...) in cases like that. Please, read the manual, http://dev.mysql.com/doc/refman/5.0/en/union.html: "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." Same rule applies to your case also.