Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Recently I was given a MySQL DB that included a field named time-taken, which caused errors when used in a select because of the minus sign.

In this case I was able to rename the field, but for future reference how can field names be quoted or escaped in a MySQL query?

share|improve this question
up vote 3 down vote accepted

Put the field in backticks.

SELECT * from `table` WHERE `int` = 0

Here's the reference page.

share|improve this answer
That would be the one type of quote I didn't try :-) – DrStalker Mar 19 '10 at 3:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.