Oracle SQL - REGEXP_LIKE contains characters other than a-z or A-Z

前端 未结 4 1398
耶瑟儿~
耶瑟儿~ 2020-12-14 08:06

I would like to create a query where I select all records which contain characters that are not a-z or A-Z

so something like this

SELECT * FROM mytable

相关标签:
4条回答
  • 2020-12-14 08:38

    Something like

    select *
      from foo
     where regexp_like( col1, '[^[:alpha:]]' ) ;
    

    should work

    SQL> create table foo( col1 varchar2(100) );
    
    Table created.
    
    SQL> insert into foo values( 'abc' );
    
    1 row created.
    
    SQL> insert into foo values( 'abc123' );
    
    1 row created.
    
    SQL> insert into foo values( 'def' );
    
    1 row created.
    
    SQL> select *
      2    from foo
      3   where regexp_like( col1, '[^[:alpha:]]' ) ;
    
    COL1
    --------------------------------------------------------------------------------
    abc123
    
    0 讨论(0)
  • 2020-12-14 08:40

    The ^ negates a character class:

    SELECT * FROM mytable WHERE REGEXP_LIKE(column_1, '[^A-Za-z]')
    
    0 讨论(0)
  • 2020-12-14 08:56

    if you want that not contains any of a-z and A-Z:

    SELECT * FROM mytable WHERE NOT REGEXP_LIKE(column_1, '[A-Za-z]')
    

    something like:

    "98763045098" or "!%436%$7%$*#"

    or other languages like persian, arabic and ... like this:

    "خلیج فارس"

    0 讨论(0)
  • 2020-12-14 09:00

    Try this:

    select * from T_PARTNER 
    where C_DISTRIBUTOR_TYPE_ID = 6 and
    translate(C_PARTNER_ID, '.1234567890', '.') is null;
    
    0 讨论(0)
提交回复
热议问题