Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2016
    Posts
    3

    Unanswered: update in mysql query

    hi friends
    eg.
    table.row1.field1=<div>hello</div>
    table.row2.field1=<div>hi</div>
    table.row3.field1=<div>by</div>

    i want to update my table : i want to remove <div>any things</div> from all row.
    like this : update table set field=REPLACE(field,"<div>%</div>",""); //this command don't work.

    sorry i can't speak en good.

  2. #2
    Join Date
    Jul 2016
    Posts
    3

    help me

    help me help me help me ! please

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    try:-
    Code:
    update table set field=REPLACE(field,"</div>","") where field like "%</div>%
    Code:
    update table set field=REPLACE(field,"<div>","") where field like "%<div>%
    or in one statement
    Code:
    update table set field=REPLACE(replace(field,"/div",""),"</div>","") where field like "%div>%
    version 1 could be 'safer' inasmuch as it replaces individual occurances of <div> and </div>
    version 2 does the same, but the filter (where clause) is div>, so it should pick up <div> and </div>column
    Last edited by healdem; 07-21-16 at 07:10.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jul 2016
    Posts
    3

    Update Query

    hi
    i want to delete <div></div> and anythings between <div></div>

    for eg:
    field1 = "this is a test <div>text</div>";
    field1 = "this is a another test <div>text1</div>";

    i want to delete "<div>text</div>" from field1 and delete "<div>text1</div>" from field2.

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    If you know the text you want to remove tgen replace would work

    If you dont know the text between the div tags then use the mysql string functions
    http://dev.mysql.com/doc/refman/5.7/...functions.html
    Use instr to find the location of the specified text, then right, mid or left fu ctions to extract what you want.
    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
  •