Search code examples
mysqldatabasespecial-charactersexecute

Replacing Special Words in MySQL Using Script


I have a table that has lots of word with ID and Text. Some rows have special words. How can I filter them? I want it to be done in SQL (MySQL).

An example column is:

1 Blah/blah/blah 

I need to make it blah blah blah or blahblahblah.

Is there anyone who can help me with script?


Solution

  • Mysql has a replace function that you can use:

    REPLACE(column_name,char_to_replace,replacement_char)
    

    so to turn blah/blah/blah to blah blah blah in your_column in some_table you would do this - you can always add a where clause to make it more specific:

    UPDATE SOME_TABLE SET YOUR_COLUMN = REPLACE(your_column,"/"," ")