user3586248
user3586248

Reputation: 163

Query to Determine Data with Characters and Numbers

I am using Oracle SQL and am looking to query a table where the PORTAL_OBJNAME starts with 'NCC_S' and then is immediately followed by a number. So for example 'NCC_S23434FJK0' should be displayed. I used the query below but it returns nothing which is not correct. Does anyone know what I'm doing wrong?

SELECT * FROM PSPRSMDEFN 
WHERE PORTAL_REFTYPE = 'C'
AND PORTAL_OBJNAME LIKE 'NCC_S%[0-9]%'

Upvotes: 0

Views: 22

Answers (1)

krokodilko
krokodilko

Reputation: 36087

Use REGEXP_LIKE function: https://docs.oracle.com/cd/B12037_01/server.101/b10759/conditions018.htm

WHERE PORTAL_REFTYPE = 'C'
AND regexp_like( PORTAL_OBJNAME, '^NCC_S[0-9]+' )

Upvotes: 1

Related Questions