How to corret this mysql select query?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nick

    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!

  • Tom Thackrey

    #2
    Re: How to corret this mysql select query?


    On 28-May-2005, "Nick" <nick_1394@yaho o.com.cn> wrote:
    [color=blue]
    > 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.[/color]

    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

    tom (at) creative (dash) light (dot) com
    do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

    Comment

    Working...