I have a query that won't work I assume because the field I'm querying is named order
SELECT id,name,order FROM tablename
How should I write this query?
msyql_query("SELECT RESERVED FROM table
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: msyql_query("SELECT RESERVED FROM table
What exactly are you trying to do?
Re: msyql_query("SELECT RESERVED FROM table
I'm trying to select a field named "order" from a table.
Re: msyql_query("SELECT RESERVED FROM table
order is a MYSQL reserved word
http://dev.mysql.com/doc/refman/5.1/en/ ... words.html
you have 2 options:
a) enclose your "order" field in backticks i.e
but that solution make your select less portable to a different database engine
or
b) rename your "order" field to something else that is nor a reserved word... This should be the preferred option when possible for portability.
http://dev.mysql.com/doc/refman/5.1/en/ ... words.html
you have 2 options:
a) enclose your "order" field in backticks i.e
Code: Select all
SELECT id, name, `order` FROM tablenameor
b) rename your "order" field to something else that is nor a reserved word... This should be the preferred option when possible for portability.