Gil Hadad
Gil Hadad

Reputation: 327

Query that returns rows that start with numeric values in Oracle

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?

Upvotes: 1

Views: 385

Answers (1)

SomeJavaGuy
SomeJavaGuy

Reputation: 7347

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

Upvotes: 5

Related Questions