Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Unanswered: Replace string in TEXT column at given position

    Hi All,

    Is it possible to replace a string in a text column at a given start end position?

    Example

    update table set text=replace(text, start, end, 'replace with');

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    you probably could using some fiendish manipulation of some of the MySQL string functions
    including replace, instr
    left and so on...
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    How about using a combination of CONCAT, SUBSTR and REPLACE for example:

    UPDATE table SET text=CONCAT(SUBSTR(text,1,start), REPLACE(SUBSTR(text, start+1, end-start), 'text to replace', 'text replaced with'), SUBSTR(text, end+1));
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Tags for this Thread

Posting Permissions

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