Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find non-breaking space in MySql

Tags:

mysql

How can I find a non-breaking space in a MySql database?

For instance between # and N:

## New Tech

I tried to select the table and click to query:

UPDATE test 
SET text = replace (text, " ", "")
WHERE id = 3;

It finds 0 results and I am sure there is

With regex I can use also:

\xA0 

But I do not know how to apply that in a MySql database

like image 861
Nrc Avatar asked Jan 30 '17 15:01

Nrc


People also ask

How do you find a non-breaking space?

Non-breaking space is a space character that prevents automatic line break. It looks identical to a normal space character. By opening an UTF-8 encoded text file in binary editor, one can check that non-breaking space is 0xC2 0xA0 while normal space is 0x20 .

How do I strip spaces in mysql?

The TRIM() function returns a string that has unwanted characters removed. Note that to remove the leading spaces from a string, you use the LTRIM() function. And to remove trailing spaces from a string, you use the RTRIM() function.

What is SQL &NBSP?

Actually   is a character entity reference in HTML, and represents the non-breaking space character. If you want to remove it, you must include the semicolon as well.

How do you remove a non-breaking space in SQL?

Removing non-breaking spacesThe REPLACE( ) function replaces any non-breaking spaces with regular spaces, and then ALLTRIM( ) removes any leading or trailing regular spaces.


1 Answers

Non-breaking spaces are often encoded as C2A0 (in hex), so you could try:

update test set text = replace(text, UNHEX('C2A0'),'')
like image 172
Kai Pommerenke Avatar answered Sep 17 '22 16:09

Kai Pommerenke