我有一个select 查询语句,其中有一栏,我想让它只含有字母和数字,怎样过滤ID     ITEM
ASD3   000
A SD   023
A#pk   5
比如上面结果,我想要ID栏只含有字母和数字的结果,其它的比如空格,#等都过滤oracle有没有类似的函数可以过滤下

解决方案 »

  1.   


    with t as
    (
    select 'ASD3' ID,'000' ITEM from dual
    union all
    select 'A SD','023' from dual
    union all
    select 'A#pk','5' from dual
    union all
    select ' ','5' from dual
    )select * from t where regexp_like(id, '^([a-z]|[A-Z]|[0-9])*$');   --只包含大小字母或数字
      

  2.   


    with t as
    (
    select 'ASD3' ID,'000' ITEM from dual
    union all
    select 'A SD','023' from dual
    union all
    select 'A#pk','5' from dual
    union all
    select ' ','5' from dual
    )select * from t where regexp_like(id, '^([a-z]|[A-Z]|[0-9])*$');   ID   ITEM
    ---- ----
    ASD3 000
      

  3.   

    正则匹配过滤  regexp_like