Thread: Question on string value expression wildcarding

Question on string value expression wildcarding

From
Steve Wampler
Date:
I have LIKE expressions:
(a)    name LIKE 'kp.dhs.%'       (b)     name LIKE 'kp.dhs%'

where the name column contains strings prefixed with "kp.dhs.".

I'm using postgresql  7.0.2.

Expression (a) fails to match any names while (b) matches
all strings prefixed with "kp.dhs", including (as expected)
those prefixed with "kp.dhs.".

So I take it that ".%" has some special meaning in wildcarding,
but my (limited) SQL references don't mention this case.
Is this To Be Expected SQL behavior?  If so, what
expression can be used to match only strings prefixed with
"kp.dhs."?

Thanks!
--
Steve Wampler-  SOLIS Project, National Solar Observatory
swampler@noao.edu


Re: Question on string value expression wildcarding

From
Stephan Szabo
Date:
Do you have any odd locale settings or anything and what's
the table definition for the table in question?

It seems to do what I expect under my 7.0.2 system:

create table kp (name text);
insert into kp values ('kp.dhs.a');
insert into kp values ('kp.dhs.');
insert into kp values ('kp.dhs,d');
select * from kp where name like 'kp.dhs.%';  name   
----------kp.dhs.akp.dhs.
(2 rows)

select * from kp where name like 'kp.dhs%';  name   
----------kp.dhs.akp.dhs.kp.dhs,d
(3 rows)

Stephan Szabo
sszabo@bigpanda.com

On Thu, 24 Aug 2000, Steve Wampler wrote:

> 
> I have LIKE expressions:
> 
>     (a)    name LIKE 'kp.dhs.%'
>         (b)     name LIKE 'kp.dhs%'
> 
> where the name column contains strings prefixed with "kp.dhs.".
> 
> I'm using postgresql  7.0.2.
> 
> Expression (a) fails to match any names while (b) matches
> all strings prefixed with "kp.dhs", including (as expected)
> those prefixed with "kp.dhs.".
> 
> So I take it that ".%" has some special meaning in wildcarding,
> but my (limited) SQL references don't mention this case.
> Is this To Be Expected SQL behavior?  If so, what
> expression can be used to match only strings prefixed with
> "kp.dhs."?