Bug #22023 LIMIT and ORDER BY ordering error in SQL SELECT statement
Submitted: 5 Sep 2006 14:38 Modified: 5 Sep 2006 14:42
Reporter: John Navratil Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.16 OS:Linux (Linux (FC4))
Assigned to: CPU Architecture:Any
Tags: limit, order by, SELECT

[5 Sep 2006 14:38] John Navratil
Description:
"SELECT ...  ORDER BY 1 LIMIT 0, 30" succeeds while "SELECT ...  LIMIT 0, 30 ORDER BY 1" generates ERROR 1064.  This may be correct behavior but it does not match the "Manual 5.0", "13.2.7. SELECT Syntax" documentation which lists ORDER BY before LIMIT.

How to repeat:
select * FROM user LIMIT 1 ORDER BY 1;

Suggested fix:
If this is valid syntax, fix parser.  If this is invalid syntax, fix documentation in 13.2.7 to show correct order of ORDER BY and LIMIT clauses.
[5 Sep 2006 14:42] John Navratil
Must not have had enough coffee!  The orders in the documentation are correct.  Sorry!