Re: SQL Where Like - Range it?! - Mailing list pgsql-general

From will trillich
Subject Re: SQL Where Like - Range it?!
Date
Msg-id 20010427160047.A26644@serensoft.com
Whole thread Raw
In response to Re: SQL Where Like - Range it?!  ("Len Morgan" <len-morgan@crcom.net>)
Responses Re: SQL Where Like - Range it?!
List pgsql-general
On Fri, Apr 27, 2001 at 09:52:26AM -0500, Len 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.

how about regex?

    select * from tbl where fld ~ '^[A-F]';

--
don't visit this page. it's bad for you. take my expert word for it.
http://www.salon.com/people/col/pagl/2001/03/21/spring/index1.html

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

pgsql-general by date:

Previous
From: Vince Vielhaber
Date:
Subject: Re: [HACKERS] While we're on the subject of searches...
Next
From: will trillich
Date:
Subject: Re: last comma inside "CREATE TABLE ()" statements