Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a table like,
ID NAME
1 AB JOHN
2 MICHAEL JOHNSON
3 ST SACHIN

I want to generate like(I want query in oracle)
ID NAME
1 AB JOHN
3 ST SACHIN

Plz help me from this

What I have tried:

SELECT *
FROM Test_V
WHERE regexp_like (name , '[]') ;
Posted
Updated 4-Sep-17 23:44pm

SQL
Select * from Test_V Where Locate(' ', Name)=3
 
Share this answer
 
Member 11416690 is on the right track using regexp_like()

Try this:
select *
from test_v
where regexp_like(' ' || name || ' ', [^[:alpha:]]+[[:alpha:]]{2}[^[:alpha:]]+)

The above will test for 2 consecutive alpha characters (letters) preceded and succeeded by at least 1 non alphabetic character. As I have not done any real testing of the query in Oracle, I am not sure whether Oracle will return a match if the 2 characters are at the start/ end of the string and that is why the prefix and suffix spaces are added to 'name' (column value). The above should match even if the 2 consecutive letters occur in the middle of the string. If you are looking to match uppercase characters use [[:upper:]]{2} but do not alter [^[:alpha:]]+.
locate(' ', name) = 3 will also match A. JOHN and S. SACHIN.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900