Home » SQL & PL/SQL » SQL & PL/SQL » Query help - Alpha characters (Oracle 10 g )
Query help - Alpha characters [message #584298] Sat, 11 May 2013 05:17 Go to next message
babhuko
Messages: 49
Registered: December 2011
Location: Chennai
Member
Hi all,

I have a requirement to fetch data that is in the below format,

**template**
**sample**

I fired the following query

select * from table where col1 like '**%**'

but it retrieves data like

****sample****
** sample**
**--sample**

But my requirement is to fetch only alpha data between ** **. Please throw some light on this. Thanks.
Re: Query help - Alpha characters [message #584299 is a reply to message #584298] Sat, 11 May 2013 05:47 Go to previous message
dariyoosh
Messages: 530
Registered: March 2009
Location: Iran / France
Senior Member
Try REGEXP_LIKE

WITH tmptab AS
(
    SELECT '****sample****' AS colval FROM DUAL UNION ALL
    SELECT '** sample**'    AS colval FROM DUAL UNION ALL
    SELECT '**sample**'     AS colval FROM DUAL UNION ALL
    SELECT '**--sample**'   AS colval FROM DUAL UNION ALL
    SELECT '**template**'   AS colval FROM DUAL
)
SELECT colval
FROM tmptab
WHERE REGEXP_LIKE(colval, '^[*]{2}[a-zA-Z]+[*]{2}$');


COLVAL
--------------
**sample**
**template**

SQL> 



Regards,
Dariyoosh

[Updated on: Sat, 11 May 2013 05:48]

Report message to a moderator

Previous Topic: Continuos job
Next Topic: SQL HELP
Goto Forum:
  


Current Time: Thu Jul 24 04:06:03 CDT 2014

Total time taken to generate the page: 0.06538 seconds