t1f
t1f

Reputation: 3181

MySQL bulk replace a character with a space

As I understand it, the REPLACE() function in MySQL requires a string to be provided. Unfortunately, I have around 16000 records that contain a , in various positions within the actual string.

I'd like to replace , with an empty space (space key, on the keyboard).

How could that be done in MySQL?

Update:

Examples:

'Dn 65-B, Km 2 + 770'
'Suciu Ioan, doctor'
'Curtici-Dorobanti, Dj 792'

Upvotes: 0

Views: 199

Answers (1)

RiggsFolly
RiggsFolly

Reputation: 94642

In your example

SELECT REPLACE("SQL Tutorial", "SQL", "HTML")

Replace the first parameter with the column name that contains the string to replace. Oh and this should go in an update statement

UPDATE tablename set colname = replace( colname, ',', ' ');

Although if you want to check what will happen, you could always run it as a select to start with, just to make sure

SELECT colname, replace( colname, ',', ' ') as theResult
FROM tablename 
LIMIT 20;

Upvotes: 1

Related Questions