1

i tried to write a query that returns rows that start with numeric values in Oracle.

for example, if the values are "123abc", "abc123", "123abc123", "1a", "a1"

it will returns: "123abc", "123abc123", "1a"

i tried this query:

SELECT * 
FROM table_name
WHERE regexp_like(column_Name,'[^0-9](*)')

where is my mistake?

Gil Hadad
  • 307
  • 1
  • 4
  • 12

1 Answers1

4

i guess you are looking for this regex:

SELECT * 
FROM table_name
WHERE regexp_like(column_Name,'^[0-9]')

or in short

SELECT * 
FROM table_name
WHERE regexp_like(column_Name,'^\d')

What you did is negate the result of the elements in the bracket, the ^ needs to be before the brackets

SomeJavaGuy
  • 7,307
  • 2
  • 21
  • 33