Jump to content

Removing a portion field data


Guest pomme_porte

Recommended Posts

Guest pomme_porte

Hi all,I have table that has a field with unrequired data that I'm trying to eliminate.Currently the field contains the string "Cost: xyz". I want to remove the "Cost: " but leave the "xyz".There are about 500 rows of data, some have "Cost: " and some don't. Also, the value of "xyz" varies in each row.I've tried a bunch of different statements but haven't been successful. I feel like I've been so far off that I don't even what to put any of those statements into this post.I have searched the tutorials and can't find an example that I can specifically apply to my situation.How do I do this in SQL?Thanks,pomme_porte

Link to comment
Share on other sites

I don't think that is possible with SQL only, but I am not an expert in this area. Unless it is possible, you could use the server-side language (ie. php) to get the the data from those rows ans save them in an array. Then use preg_replace() to replace the unwanted string part by nothing. After it has been replaced, restore it into the database in the same order when you got the array out. Is that good for you?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...