Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2007
    Posts
    3

    Unanswered: 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?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    update products
       set description = replace(description,'the phrase','')
     where description like '%the phrase%'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2007
    Posts
    3
    ok thanks a million, i'll try that!

  4. #4
    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(" ")?

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •