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.

UPDATE daTable
   SET productcode = REPLACE(productcode,'SKU','WH')
 WHERE productcode LIKE 'SKU%'


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.

thanks, that’s good to hear :slight_smile:

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.