1

I've tried select REPLACE(' this is a user name', ' ', '') and it gives me 'thisisausername' which is supposed to be.

My problem is, when I try to use REPLACE on selecting a table column, it doesn't work!

My query:

SELECT REPLACE(UserName, ' ', '') as UserName FROM MY_TABLE

it still gives me usernames with spaces! Am I doing something stupid?

reVerse
  • 35,075
  • 22
  • 89
  • 84
Eytch
  • 733
  • 3
  • 8
  • 19

1 Answers1

5

@AlexK. it's 160 for unicode(left(field, 1))

160 is Unicode NO-BREAK SPACE so that's what you need to replace:

replace(UserName, char(160), '')

You could update everything replacing char(160) with a whitespace ' ' and then just use your original query in the future (perhaps also ensuring such values cannot be entered in the future)

Alex K.
  • 171,639
  • 30
  • 264
  • 288