Remove invisible backspace characters from mysql d

2019-09-14 07:43发布

问题:

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%'