RobM
RobM

Reputation: 11

MySQL search and replace apostrophe in serialized data

I'm trying to find instances of a "|" (pipe) character in a field containing serialized data and replace it with a " ' " character (apostrophe).

I've tried this:

UPDATE postmeta SET meta_value = Replace(meta_value, '|', ''');

And this...

UPDATE postmeta SET meta_value = Replace(meta_value, '|', '"'"');

And this...

UPDATE postmeta SET meta_value = Replace(meta_value, '|', ''');

Also, this...

UPDATE postmeta SET meta_value = Replace(meta_value, '|', '\'');

Each result in errors.

Upvotes: 1

Views: 92

Answers (2)

Pathik Vejani
Pathik Vejani

Reputation: 4491

Try this :

UPDATE postmeta SET meta_value = Replace(meta_value, '|', "'");

Upvotes: 0

M0rtiis
M0rtiis

Reputation: 3784

http://dev.mysql.com/doc/refman/5.6/en/string-literals.html#character-escape-sequences

UPDATE postmeta SET meta_value = Replace(meta_value, '|', '''');

Upvotes: 1

Related Questions