Bug #18786 order by field does not work if there is a space
Submitted: 5 Apr 2006 1:02 Modified: 5 Apr 2006 1:06
Reporter: [ name withheld ] Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S5 (Performance)
Version:3 OS:Windows (windows)
Assigned to: CPU Architecture:Any

[5 Apr 2006 1:02] [ name withheld ]
Description:
When you sort using "ORDER BY FIELD" if there is a space after that it doesn't work. For example, this works:

SELECT * FROM people WHERE person_id IN (10, 20)  ORDER  BY FIELD(person_id, 20, 10) 

but this does not:

SELECT * FROM people WHERE person_id IN (10, 20)  ORDER  BY FIELD (person_id, 20, 10)

All just because I put in a space after "FIELD".

How to repeat:
Just write a query w/ a space after the FIELD keyword.
[5 Apr 2006 1:06] Jim Winstead
The requirement for no space after a function name is documented at
http://dev.mysql.com/doc/refman/5.0/en/functions.html

You can use the IGNORE_SPACE SQL mode in MySQL 5.0 or later to lift this limitation.