user2728627
user2728627

Reputation: 89

how to remove whitespace between two words in mysql

I have a record like Z Ion Fort. Now I want to combine the word like as follows ZIon Fort,for that I had written a update query like

 update sample1 set sname=replace(sname,' Ion ','Ion ');

But it is not working.

Upvotes: 0

Views: 1472

Answers (1)

Fabien TheSolution
Fabien TheSolution

Reputation: 5050

SQL Fiddle

MySQL 5.5.32 Schema Setup:

CREATE TABLE sample1
    (`sname` varchar(36))
;

INSERT INTO sample1
    (`sname`)
VALUES
    ('Z Ion Fort Z Butol (800 mg)')
;



update sample1 set sname=replace(sname,'Z ','Z');

Query 1:

select *
from sample1

Results:

|                     SNAME |
|---------------------------|
| ZIon Fort ZButol (800 mg) |

Upvotes: 2

Related Questions