SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    marijampole
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    replacing using select?

    hey guys got another weird quastion for you hope you can help me again hehe

    i got a table

    id title date size
    ex. 1 ok;yes 2-27-04 5
    ex. 2 ok;no 2-27-04 10

    is there a way i could search like %;% and every rls rls it finds replace the ; with another char or ""? need to take out that char because my other scripts messed up on it on about 67k rows anyways let me know if you guys have any ideas and ofc mysql queries welcome since I'm not good at all at more rare queries as you've seen from my older quastions hehe
    thanks, Jonas once again

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    i would use the mysql REPLACE function

    you can use in a SELECT, as you suggest, and you can also use it in an UPDATE if you wanted to replace that character permanently
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    marijampole
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    erm think you could help me out with the query for the replace part ? :s lol i always read the mysql manual and have no idea what the hell they're saying half the time
    so far i got
    REPLACE *
    SELECT * FROM `products`
    WHERE `title` LIKE '%;%';
    and thast about it =/ lol

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,251
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    REPLACE function, not REPLACE command
    Code:
    update products
       set title = replace(title,';','')
     where title like '%;%'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2005
    Location
    marijampole
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    woot you're a life saver once again hope you never leave this place lol thanks once more m8


Bookmarks

Posting Permissions

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