Reputation: 3
I have a question for you. I have two columns that returns the duo of countries for electricity exchange. the values look something like this:
**Area_in** IT-NORTH-FR
**Area_out** IT-NORTH-AT
and there are many more values with IT-north-and(Germany for example)
I need a way of altering the values in both columns so that when these areas appear, only the name “IT-NORTH” gets returned
I don't want to create a new column by using case function. just updating the name. how can it be done
Upvotes: 0
Views: 25
Reputation: 7240
Try this:
update yourtable set Area_in='IT-NORTH' where left(Area_in,8)='IT-NORTH'
update yourtable set Area_out='IT-NORTH' where left(Area_out,8)='IT-NORTH'
However, this will create duplicates if you have several rows of one column having 2+ it-north variants with the other col having the same value.
Upvotes: 1