954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

SQL function to auto find and replace?

Hi, ok I have about 1600 records in a mySQL db. Many of them have a forward slash "/" in the itemName column. In my site, I am passing the itemName as a URL variable on many search forms, so obviously the forward slash is not a good naming convention to use.

IS there a way to go in my db and find and replace all instances on the forward slash? I usually use navicat for db management, and it has a find feature, but you have to replace each forward slash it finds by hand. Thanks for any suggestions in advance!

teedoff
Posting Pro
599 posts since Jul 2010
Reputation Points: 21
Solved Threads: 60
 

For a table named 'items':

update items set itemName = replace(itemName,'/','');
d5e5
Practically a Posting Shark
812 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159
 

Awesome! This will only replace the "/" in the column I specify correct? What I mean is there are forward slashes in other columns, but since they are not used in variables I might pass in a url, I want to leave them. Thanks!

teedoff
Posting Pro
599 posts since Jul 2010
Reputation Points: 21
Solved Threads: 60
 

Yes, it replaces only the specified string in the specified column. Forward slashes in other columns won't change.

d5e5
Practically a Posting Shark
812 posts since Sep 2009
Reputation Points: 159
Solved Threads: 159
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You