Maxim Alexandru
Maxim Alexandru

Reputation: 77

Is there a multibyte-safe MySQL function which can replace potentially accented letters?

In my database I have values containing Romanian diacritics and should be Ă but are saved as ă.

All I want to do is to replace all ă substrings with Ă.

For example if I have:

How can I do that?

Upvotes: 2

Views: 3433

Answers (3)

Yoann
Yoann

Reputation: 66

MySQL defines a function called REPLACE that does exactly like PHP's str_replace.

You can use it to replace all occurences of a string in a column by doing :

UPDATE table SET column = REPLACE(column,  'ă', 'Ă');

The documentation of this function can be found at : http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace

Upvotes: 2

Ajitha Ms
Ajitha Ms

Reputation: 555

You may try this

UPDATE table_name
SET column_name = REPLACE(columnname, 'find_string', 'replace_with')

Upvotes: 5

Xavjer
Xavjer

Reputation: 9264

All string functions for Mysql can be found here: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html

You should try replace: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace

Upvotes: 0

Related Questions