Finbarr
Finbarr

Reputation: 32126

What is wrong with this SQL syntax?

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'

Upvotes: 1

Views: 119

Answers (3)

Bill Karwin
Bill Karwin

Reputation: 562330

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

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

Upvotes: 2

Hammerite
Hammerite

Reputation: 22340

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.

Upvotes: 2

Matteo Riva
Matteo Riva

Reputation: 25060

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

Upvotes: 12

Related Questions