Reputation: 473
I am working with a project where a requirement which i face is as follows I have some scenario to check as follows The input in database will be a String Starting with constant character QWER it can be followed by number,character set and even by a special character like _,# and so on . sample inputs are QWER0000001,QWERD00909,QWER32_333,QWER32-333 and so on
I need to filter all only the values that contain QWER and followed by number only from above cases expected result is only QWER0000001 the query i tried in is as follows
select c.request_Id
from TABLE c
where UPPER(c.request_Id) not like 'QWER%[A-Z]'
and c.request_Id like 'QWER[0-9]%'
now it filters the the data that contain special characters also . how to filter the unwanted spl charecters set .expecting a query that forks fine in both oracle and sql
Upvotes: 0
Views: 288
Reputation: 311308
You could use regexp_like
with a regular expression:
SELECT *
FROM c
WHERE REGEXP_LIKE(request_id, '^QWER[0-9]+$');
Upvotes: 2