msyql_query("SELECT RESERVED FROM table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ThaJock
Forum Newbie
Posts: 11
Joined: Tue Nov 04, 2008 10:15 pm

msyql_query("SELECT RESERVED FROM table

Post by ThaJock »

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?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: msyql_query("SELECT RESERVED FROM table

Post by Jonah Bron »

What exactly are you trying to do?
ThaJock
Forum Newbie
Posts: 11
Joined: Tue Nov 04, 2008 10:15 pm

Re: msyql_query("SELECT RESERVED FROM table

Post by ThaJock »

I'm trying to select a field named "order" from a table.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: msyql_query("SELECT RESERVED FROM table

Post by mikosiko »

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

Code: Select all

 SELECT id, name, `order` FROM tablename
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.
Post Reply