www.webdeveloper.com
Results 1 to 3 of 3

Thread: Updating parts of SQL Data

  1. #1
    Join Date
    Jun 2004
    Location
    California, USA
    Posts
    264

    Updating parts of SQL Data

    Hello,

    I am trying to update part of SQL data but am not getting it to work. Here is my example. I have a row that has the data "apple.mid" in a column called url. I want to change the extension of the data to "apple.zip". Is there a way to only change part of the data?

    I tried this:
    UPDATE dir_pages
    SET url = url+'.zip'
    WHERE url like '%.mid' AND id = '2'

    But I am not getting the right value.
    Thank you,
    MIDI Delight - Free Ringtones and MIDI Files
    http://www.mididelight.com

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,921
    If you are using MySQL, this might do the trick:
    Code:
    UPDATE dir_pages SET url = REPLACE(url, '.mid', '.zip')
    WHERE url like '%.mid' AND id = '2';
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jun 2004
    Location
    California, USA
    Posts
    264
    and that worked! thank you, didnt even know there was a replace function in mysql
    Thank you,
    MIDI Delight - Free Ringtones and MIDI Files
    http://www.mididelight.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles