Very simple
I have a column of string like that :
abc1
abc2
abc3
abc4
abc5
I need to remove ‘abc’ from this column and keep only the number on the right, so column would have only the number like :
1
2
3
4
5
I thought about smth like that but it doesn’t work
update table2
-> set col1 = case when 'abc1' then 1
-> else end;
I know how to concat text, I don’t know how to undo it… Help please ^^;
@McArthey already hinted at it, but this is easy to do when the “abc” is consistently “abc” (i.e. the length doesn’t change.)
Amongst the various string functions is one in particular:
RIGHT(). This allows you to select a fixed number of characters from a string. e.g.Coupled with the
LENGTH()function, you can conclude the numbers are anything past the 3rd character. i.e.Obviously I’m using hard strings (
'abc3'), but these can easily be replaced with column names.The caveat here is that these all are based on fixed length letter prefixes. The more variable (changing) the “abc” in your example is, the harder picking the numeric value out of the column becomes.