Hi folks,

I have a general question to MySQL, how can I replace a single character in a mysql field, for example, somebody entered a name like "name". So how do I get only the "-signs out of this field. I found the replace function but it kinda doesn't work for me.
Thanks for any hints.

Comments

wickus’s picture

Or better said, how do I apply this function to a whole column.
Thanks

mdixoncm’s picture

something like

update yourtable set field1=REPLACE(field1,'-','');

NOTE - be very careful when doing an update cos it might go wrong and my code might be rubbish - do a test with something like

SELECT *,REPLACE(field1,'-','') FROM yourtable

just to make sure that the replace is doing what you want it to first

good luck

mike

Like books? Check out booktribes the new (Drupal based) community for book lovers
from Computerminds