3

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?

DrStalker
  • 6,946
  • 24
  • 79
  • 107

1 Answers1

6

Put the field in backticks.

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

Here's the reference page.

squillman
  • 37,883
  • 12
  • 92
  • 146