471,319 Members | 1,685 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

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!

Jul 17 '05 #1
1 1263

On 28-May-2005, "Nick" <ni*******@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 ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Gordon | last post: by
reply views Thread by Lenz Grimmer | last post: by
reply views Thread by Philip Stoev | last post: by
reply views Thread by Mike Chirico | last post: by
13 posts views Thread by Ciaran | last post: by
Atli
6 posts views Thread by Atli | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.