Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2011
    Posts
    32

    Unanswered: Removing a Part of Text from Database Field

    Hi,

    I have the following in a field, which appears in many records:

    common-words/someword

    I wanna to change this to

    expressions/someword

    How should I write the SQL query for this.

    Appreciated...

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    UPDATE daTable
       SET afield = REPLACE(afield,'common-words/someword','expressions/someword')
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jul 2011
    Posts
    32
    hmmm.....

    Actually 'someword' means there are many records of different words in the table, i.e.

    common-words/mufassir
    common-words/muhaddith
    common-words/faqiih
    common-words/muhaqqiq
    ....

    I wanna to change all these records to, lets say:

    expressions/mufassir
    expressions/muhaddith
    expressions/faqiih
    expressions/muhaqqiq

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    UPDATE daTable
       SET afield = REPLACE(afield,'common-words/','expressions/')
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Jul 2011
    Posts
    32
    Oops.. there is a REPLACE function for that, I need to get some proper training for SQL.


    Thanks.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    well its either that or look at da manuel
    or possibly both
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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