1
UPDATE files 
SET filepath = REPLACE(filepath, `sites/somedomain.com/files/`, `sites/someotherdomain.com/files/`);

I have a table called files with a field called filepath. MySQL returns this error: Unknown column 'sites/somedomain.com/files/' in 'field list'

Finbarr
  • 31,350
  • 13
  • 63
  • 94

3 Answers3

12

Use normal quotes instead of backquotes: normal quotes identify strings, backquotes identify column names.

Matteo Riva
  • 24,728
  • 12
  • 72
  • 104
2

To expand on kemp's answer:

Backquotes or backticks ` are used in MySQL to enclose the names of schema objects (databases, tables, columns, indexes, procedures, ...). They cannot be used to enclose strings. You must use regular single- or double-quotes: ' or " for that.

Hammerite
  • 21,755
  • 6
  • 70
  • 91
2

+1 to answers given by @kemp and @Hammerite.

See also my answer to this question: Do different databases use different name quote?

Community
  • 1
  • 1
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • +1 this link is worth reading. If you want to ensure cross-database compatibility without having to write DBMS-dependent quoting code or DBMS-specific settings configuration stuff, you have to omit quotes for schema names altogether—which unfortunately also means you have to be very careful naming your tables and columns to avoid reserved words. This is a nasty mess. – bobince Jun 01 '10 at 23:08