SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2012
    Location
    Orlando
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Update Partial data in a column

    Hello Great Forum

    I have an e- commerce database (x-cart) that has all the productcodes starting with SKU??????

    I would like to change all the items that begin with SKU and replace that with a WH


    The digits after the SKU will stay there and all I will be replacing is the SKU with WH

    In cpanel with PHPadmin I can do one at a time of course but that does not seem like a great idea when we have SQL. I think I have 600 items in the column that I want to change from SKU to WH.

    I know I have to do an update for that column but I cannot figure it out,

    What would be really nice is to replace the SKU with WH1001 and increment each item by 1 so the next item I replace would be WH1002, WH1003.

    Anyway replacing the SKU with the WH is the key.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    UPDATE daTable
       SET productcode = REPLACE(productcode,'SKU','WH')
     WHERE productcode LIKE 'SKU%'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Jun 2012
    Location
    Orlando
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello

    Thank you I would have never figured this out. I purchased the sitepoint book SIMPLY SQL and I could not wrap my brain on how to do this. I am going to give it a try as soon as I get to my desk.

    BTW. I do like the book.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by caucus1 View Post
    BTW. I do like the book.
    thanks, that's good to hear
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Member
    Join Date
    Jun 2012
    Location
    Orlando
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Again

    Wow, SQL is the greatest thing since "Carter had Liver Pills" Hopefully I can manipulate data the way I want and know what I am doing. Thanks again for the help.


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
  •