Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace NonASCII Characters in MYSQL

Tags:

sql

mysql

To convert NON ASCII Characters to ASCII I used the below query

UPDATE tablename
SET columnToCheck = CONVERT(columnToCheck USING ASCII)
 WHERE columnToCheck <> CONVERT(columnToCheck USING ASCII)

It replaces the NON ASCII characters into replacement characters. But is it possible to replace those Non Ascii characters to SPACES.

I tried some options, but its not working. Any suggestion.

like image 529
user3127462 Avatar asked Dec 24 '13 21:12

user3127462


1 Answers

Try this one

UPDATE tablename
SET columnToCheck = REPLACE(CONVERT(columnToCheck USING ascii), '?', '')
WHERE ...

or

update tablename
set columnToCheck = replace(columnToCheck , char(146), '');

Reference

like image 78
M Khalid Junaid Avatar answered Sep 18 '22 10:09

M Khalid Junaid