Remove invisible backspace characters from mysql data

蓝咒 提交于 2019-12-25 07:18:17

问题


I have the following invisible character in my dataset

Which I believe is this character

http://www.fileformat.info/info/unicode/char/0008/index.htm

How do I remove this? I've tried

UPDATE events SET `value` = TRIM(REPLACE(`value`, CONVERT(char(8) USING hp8), ''))


回答1:


MySQL escape sequence for literal backspace character is \b.

See "Special Character Escape Sequences" here:

http://dev.mysql.com/doc/refman/5.7/en/string-literals.html


If I needed to remove that character from a string column, I'd use an expression like this:

 REPLACE(foo,'\b','')

I'd test that expression in a SELECT statement before I tried an UPDATE, e.g.

SELECT t.foo
     , REPLACE(t.foo,'\b','')` AS new_foo
  FROM mytable t
 WHERE t.foo LIKE '%\b%'


来源:https://stackoverflow.com/questions/39420442/remove-invisible-backspace-characters-from-mysql-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!