mySQL Query Browser errors

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

    #1

    mySQL Query Browser errors

    Does mySQL not like dashes or something? I seem to be getting the
    following error:

    "Unknown column 'etrans' in 'where clause'"

    when I do the following query:

    SELECT * from expense where etrans-num > 25

    If I try:

    SELECT * from expense where expense.'etrans-num' > 25

    I get:

    "You have an error in your SQL syntax, Check the manual that
    corresponds to your MySQL version for the right syntax to use near
    "etrans-num' > 25' at line 1

    What's wrong with using dashes in field names?????

    PW
  • Bill Karwin

    #2
    Re: mySQL Query Browser errors

    PW Herman wrote:[color=blue]
    > What's wrong with using dashes in field names?????[/color]

    They're too easily confused with the subtraction operator.
    FWIW, I can't think of a single programming language that permits dashes
    in identifiers.

    MySQL uses backticks `` as an identifier delimiter, if you need special
    characters, spaces, reserved words, etc. in your field names.

    Try this:
    SELECT * from expense where expense.`etrans-num` > 25

    Regards,
    Bill K.

    Comment

    Working...