MYSQL function space error

By default, there must be no whitespace between a function name and the parenthesis following it. This helps the MySQL parser distinguish between function calls and references to tables or columns that happen to have the same name as a function. However, spaces around function arguments are permitted.

Example:
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 between "FIELD" and the "(".

Leave a Reply

Your email address will not be published. Required fields are marked *