Skip site navigation (1) Skip section navigation (2)

Re: SQL Where Like - Range it?!

From: Sterling <smullett(at)omeninc(dot)com>
To: Sterling <smullett(at)omeninc(dot)com>
Subject: Re: SQL Where Like - Range it?!
Date: 2001-04-27 20:07:55
Message-ID: 3AE9D19B.7430B804@omeninc.com (view raw or flat)
Thread:
Lists: pgsql-general
H-

Thanks again. 

Being slow at times I know why ~* '^[A-F]' wasn't working. 

Yeah, that's right. There weren't any records in that range. I moved it
up and pulled some records in a range of A-P and it worked as expected. 

Thanks to all that wrote in and replied. I understand why the LIKE 'A%'
AND LIKE 'F%' wasn't working now also. 
Or why it wouldn't work if there were records there. 

Hope everyone has a good weekend. 
Back to the code. 
-Sterling


Sterling wrote:
> 
> H-
> 
> Thank you to all that have replied.
> 
> Unfortunately none of the examples provided worked for me on my system.
> 
> I tried:
> SELECT * from table where last_name BETWEEN 'A' AND 'G';
> SELECT * from table where last_name >='A' AND last_name<'G';
> SELECT * from table where last_name ~* '^[A-F]';
> 
> to no avail. 8^(
> 
> I didn't find a between function in the postgres documentation.
> 
> Is that some special function? I'm using PostgreSQL 6.5.3.
> 
> If anyone has any further thoughts please drop a line.
> Thanks again and hopefully something will work out.
> -Sterling
> 
> en Morgan wrote:
> >
> > >What I'd like to do is pull a list of records where there is a range of
> > >last names; say from A - F.
> > >select * from table where last_name LIKE 'A%' AND last_name LIKE 'F%' -
> > >for example.
> > >
> > >The above code I've tried for this doesn't seem to work as I'd expect it
> > >too?
> >
> > SELECT * FROM table WHERE last_name BETWEEN 'A' AND 'Fzzzzzzzzzzzzz' ;
> > worked for me.
> >
> > You could also use BETWEEN 'A' AND 'G' to avoid all of the zzzzzzzzs at the
> > end.  Crude but effective.
> >
> > len morgan
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> > message can get through to the mailing list cleanly

In response to

pgsql-general by date

Next:From: Jan WieckDate: 2001-04-27 20:12:27
Subject: Re: PostgreSQL and mySQL database size question
Previous:From: Feite BrekeveldDate: 2001-04-27 20:00:00
Subject: FATAL 2 : after a vacuum, can't start postmaster anymore

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group