sql - How to update record from alphanumeric to numeric only? -


topic : data cleaning - checking outlier - out of pattern

i'm trying update custid value 'a123' '123', '22a4' '224' want keep integer inside custid, don't want custid contain non-integer character (a z , z)

create table customer ( custid varchar2(10) primary key, custname varchar2(30) ); insert customer(custid,custname) values ('a123','angel'); insert customer(custid,custname) values ('22a4','chris'); insert customer(custid,custname) values ('2333','chris');  update customer set custid =            -- want change 'a123' '123', '22a4' '224'         ; 

use this...

update customer set custid = regexp_replace(custid, '[^0-9]+', '')         ; 

or try this...

update customer set custid = regexp_replace(custid, '[^[:digit:]]+', '')         ; 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -