Manga Black
Manga Black

Reputation: 197

MySQL REPLACE() to remove whitespaces

|      382 | Ongoing     |
|      383 | Ongoing     |
|      384 | Ongoing     |
|      385 | Ongoing     |
|      386 | 
Ongoing
   |
|      387 | 
Ongoing
   |
|      388 | 
Ongoing
   |
|      389 | 
Ongoing
   |
|      390 | 
Ongoing
   |
|      391 | 
Ongoing

Above is my SQL, somehow I did some mistake when inserting the values.

I want to do a string replace to replace the empty "spaces".

I did the following

update content set status = replace(status,' ','');

It replace 19 rows, then I tried again, it replace 0 rows. but the empty spaces still exist.

How do I solve this using REPLACE() in MySQL?

Upvotes: 0

Views: 89

Answers (2)

Manga Black
Manga Black

Reputation: 197

Found it..

UPDATE content set status = TRIM(Replace(Replace(Replace(status,'\t',''),'\n',''),'\r',''));

Upvotes: 0

Muhammet Arslan
Muhammet Arslan

Reputation: 985

You're looking for TRIM.

UPDATE FOO set FIELD2 = TRIM(FIELD2);

Upvotes: 1

Related Questions