You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by duschhaube <du...@gmx.net> on 2005/10/26 16:20:19 UTC

Regular Expressions

Hi!


Is it possible to use regular expressions in a select statement.

for example select * from test where name="a*b"

ciao

Re: Regular Expressions

Posted by Suresh Thalamati <su...@gmail.com>.
duschhaube wrote:
> Hi!
> 
> 
> Is it possible to use regular expressions in a select statement.
> 
> for example select * from test where name="a*b"
> 
> ciao
> 

I don't think you can do that way.  Using  the like operator, one can 
do some pattern matching in Derby.

For Example:
create table t2(name char(30) ) ;
insert into t2 values('ab') ;
insert into t2 values('acccb') ;
insert into t2 values('acccc') ;

To retrive  the name starting with 'a' and ending with 'b'

ij> select * from t2 where names like 'a%b%' ;
NAMES
------------------------------
ab
acccb

you can find more info about like operator in the following doc:
http://db.apache.org/derby/docs/10.1/ref/rrefsqlj23075.html
--



Hope that helps
-suresht


Re: Regular Expressions

Posted by duschhaube <du...@gmx.net>.
Michael J. Segel wrote:

>On Wednesday 26 October 2005 09:20, duschhaube wrote:
>  
>
>>Hi!
>>
>>
>>Is it possible to use regular expressions in a select statement.
>>
>>for example select * from test where name="a*b"
>>
>>ciao
>>    
>>
>
>Maybe its just your example, but what you're asking for is for all rows where 
>the field name matches the string "a*b". That is, Name is a string.
>
>Is that really what you are trying to do, or
>did you mean can you prepare a statement like
>"SELECT * FROM test WHERE name = ?"
>then when you execute it, you pass in your variable...
>
>Is that what you wanted?
>  
>
If I use the prepare statement, i have to create the variables by my 
self. this is not realy what I need. but I think 'like' is what i'm 
looking for.
select * from test where name like 'a%b'

this is exactly what I need.



Re: Regular Expressions

Posted by "Michael J. Segel" <ms...@segel.com>.
On Wednesday 26 October 2005 09:20, duschhaube wrote:
> Hi!
>
>
> Is it possible to use regular expressions in a select statement.
>
> for example select * from test where name="a*b"
>
> ciao

Maybe its just your example, but what you're asking for is for all rows where 
the field name matches the string "a*b". That is, Name is a string.

Is that really what you are trying to do, or
did you mean can you prepare a statement like
"SELECT * FROM test WHERE name = ?"
then when you execute it, you pass in your variable...

Is that what you wanted?

-- 
Michael Segel
Principal
MSCC
(312) 952-8175