Problem with mysql issue

Discussion in 'MySQL' started by Goonline, Jan 21, 2006.

  1. #1
    Hi

    I would like to know how can i delete a part of a text in a record on mysql databse



    Example text

    "i have to go"

    If i want to delete only the :

    i have

    From the Sentence how do i do that on enire field records


    Thank you
    Good day
     
    Goonline, Jan 21, 2006 IP
  2. Goonline

    Goonline Well-Known Member

    Messages:
    239
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    130
    #2
    Please if you cann add a sample
     
    Goonline, Jan 21, 2006 IP
  3. discoverclips

    discoverclips Peon

    Messages:
    491
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    perhaps do it with php?
    put everything in a $var and use something like $var = substr($var,pos1,pos2) and then update the sql query with UPDATE table SET item='$var'
     
    discoverclips, Jan 21, 2006 IP
  4. blinxdk

    blinxdk Peon

    Messages:
    660
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'd use php and regular expressions.
     
    blinxdk, Jan 21, 2006 IP
  5. Goonline

    Goonline Well-Known Member

    Messages:
    239
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Thank you

    I am looking to do it in sql straight on the database

    Please add a sample
     
    Goonline, Jan 21, 2006 IP
  6. l234244

    l234244 Peon

    Messages:
    1,225
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    0
    #6
    UPDATE table_name SET info='to go' WHERE info='i have to go'"

    Obviously alter table_name and info
     
    l234244, Jan 21, 2006 IP
  7. Goonline

    Goonline Well-Known Member

    Messages:
    239
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    130
    #7
    Thank you but i need to do it on 500 records at once

    How do i do that ?

    Thank you
     
    Goonline, Jan 21, 2006 IP
  8. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #8
    
    UPDATE table SET col = REPLACE(col, 'old text', 'new text')
    
    Code (markup):
    and 'new text' can be '' to replace it with nothing aka remove the 'old text'
     
    frankm, Jan 21, 2006 IP
  9. Goonline

    Goonline Well-Known Member

    Messages:
    239
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    130
    #9
    Thank you all done deal
     
    Goonline, Jan 21, 2006 IP
  10. l234244

    l234244 Peon

    Messages:
    1,225
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Sorry I misinterpreted, I thought you meant just the one record.
     
    l234244, Jan 21, 2006 IP