If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > line of code for "find & replace/delete"

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-15-07, 02:02
fsctke fsctke is offline
Registered User
 
Join Date: Jan 2007
Posts: 3
line of code for "find & replace/delete"

I have mysql type db in which I need computer to search for a key phrase of text that has several hundred occurances inside product table descriptions of products on live site. Once it finds the text, I would like for it to simply remove it, and look for the next occurance of the phrase and repeat the process until all are flagged and removed. I was told their may be a line of sql code that employs such a feature. Can anyone tell me what such a line would be?
Reply With Quote
  #2 (permalink)  
Old 01-15-07, 03:51
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
update products
   set description = replace(description,'the phrase','')
 where description like '%the phrase%'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-15-07, 03:55
fsctke fsctke is offline
Registered User
 
Join Date: Jan 2007
Posts: 3
ok thanks a million, i'll try that!
Reply With Quote
  #4 (permalink)  
Old 01-15-07, 10:35
fsctke fsctke is offline
Registered User
 
Join Date: Jan 2007
Posts: 3
Where abouts in this SQL code do I place the text to be replace ("Est.Retail Price") and where abouts do I enter the text that will replace it(" ")?
Reply With Quote
  #5 (permalink)  
Old 01-15-07, 10:44
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
right there -- i showed you where, in post #2

look up the REPLACE function in the docs, and see which parameter is for what purpose

then try to see how the parameters that i used in post #2 correlate with what you're trying to do

it's all right there

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On