Louis Shiggy Lombardi Louis Shiggy Lombardi - 2 years ago 85
SQL Question

Replace a character in multiple mysql database column

Hello I am new to mySQL and i am having trouble trying extracting data from my db by using keywords. I have 2 columns (tags and categories). I have done this before using the LIKE '%keyword%' in my query. The problem is in the db i am using now each keyword is separated with a ';' i would like to know if it is possible to somehow separate each keyword by replacing the semi-colon with a space? Or if it's easier use the same query but instead of using '%' to separate i use semi-colons? sorry if its a newbie question but i am struggling hard with this and really need some help.


Answer Source

You can replace semi-colon with space ( or any other ) with REPLACE function :

UPDATE MyTable SET tags = REPLACE(tags,';',' '), categories = REPLACE(categories,';',' ')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download