I’m currently moving a large PHP-based webapp from one server to another. The old server is running MySQL 5.0.51a (on SuSE Linux), the new server is running MySQL 5.5.15 (on ArchLinux).
Now, the new MySQL is complaining about the following statement (Syntax Error):
SELECT DISTINCT(field) FROM config WHERE range='global' ORDER BY field
I did a bit of testing and found out that the following shortened statement still fails (with Syntax Error):
SELECT * FROM config WHERE range='global'
Unfortunately, this looks like perfectly legal SQL to me. My guess is that it has to do with the type of column range, which is enum('global', 'user'). Selecting from other columns, e.g. columns of type int, works perfectly fine.
I know how to fix this issue locally, i.e. adding the column name to the where-clause, like this:
SELECT * FROM config WHERE config.range='global'
But I don’t want to go through the whole code, adding column names to SQL statements where appropriate.
Hence my question:
How do I tell MySQL 5.5.15 to accept the somewhat sloppy 5.0.51a syntax?
RANGE is a reserved word in mysql 5.5 see list
Protect your field, it sould work: