Skip to content
Advertisement

How to search for a name in where Oracle with string and number character

I need to find records in Oracle that have only such record like ‘string|number|number|number|number|number’ for example – ‘A12345’

select * from base where column_x like 'string|number|number|number|number|number'

Advertisement

Answer

That’s a letter followed by 5 digits:

SQL> with test (col) as
  2    (select 'A12345' from dual union all
  3     select 'B123CD' from dual union all
  4     select '123ABC' from dual
  5    )
  6  select *
  7  from test
  8  where regexp_like(col, '^[[:alpha:]]{1}[[:digit:]]{5}$');

COL
------
A12345

SQL>
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement