How to corret this mysql select query?

This is a discussion on How to corret this mysql select query? within the PHP Language forums, part of the PHP Programming Forums category; hi, all I convert some code from access to mysql. And I have a InboxMessage table which has From and ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-29-2005
Nick
 
Posts: n/a
Default How to corret this mysql select query?

hi, all
I convert some code from access to mysql. And I have a InboxMessage
table which has From and To field.
So, the query is like:
select * from InboxMessage where To=12
12 is user id.
This query works fine in access. But does not work in Mysql.
I think the problem is the field To, which must be a keyword in mysql.
So, how to fix this? I don't want to change the field, becuase this
will need to change a lot of code.
Thanks and have a great day!

Reply With Quote
  #2 (permalink)  
Old 05-29-2005
Tom Thackrey
 
Posts: n/a
Default Re: How to corret this mysql select query?


On 28-May-2005, "Nick" <nick_1394@yahoo.com.cn> wrote:

> I convert some code from access to mysql. And I have a InboxMessage
> table which has From and To field.
> So, the query is like:
> select * from InboxMessage where To=12
> 12 is user id.
> This query works fine in access. But does not work in Mysql.
> I think the problem is the field To, which must be a keyword in mysql.
> So, how to fix this? I don't want to change the field, becuase this
> will need to change a lot of code.


to is indeed a reserved word for mysql. Reserved words can be enclosed in
back-ticks (not apostrophes) to use them as column names, so your query
would be:

select * from InboxMessage where `To`=12


--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to jamesbutler@willglen.net (it's reserved for spammers)
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:51 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0