MYSQL Update H251*R119336 with R119336

11 Views Asked by At

I want to update field mpn with a part of field model. All records in field model with the string *R119336 have to copied to field mpn.

Fields: model -> mpn

Examples:

H251*R119336 will be R119336

HA3251*R905678 will be R905678

I do not know how to create a working SQL for this one. Hope you will help me.

1

There are 1 best solutions below

0
On BEST ANSWER

If the issue is finding the value after the *, then use substring_index():

select substring_index(model, '*', -1)

As an update:

update t
    set mpn = substring_index(model, '*', -1);