Guest pomme_porte Posted August 29, 2006 Share Posted August 29, 2006 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 More sharing options...
Jack McKalling Posted August 29, 2006 Share Posted August 29, 2006 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 More sharing options...
aspnetguy Posted August 29, 2006 Share Posted August 29, 2006 use REPLACE()http://www.sqlteam.com/item.asp?ItemID=7386 Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 29, 2006 Share Posted August 29, 2006 Cool I was right after all, about the fact that I may be wrong :)I didn't know the replace() function of SQL, now I do. Link to comment Share on other sites More sharing options...
murfitUK Posted August 29, 2006 Share Posted August 29, 2006 Well, you learn something new everyday! This will be useful to me too as I didn't know about it either.I wish I knew all the other things that I didn't know about - things would be so much easier! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now