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

Re: SQL Where Like - Range it?!

From: will trillich <will(at)serensoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL Where Like - Range it?!
Date: 2001-04-27 21:00:47
Message-ID: 20010427160047.A26644@serensoft.com (view raw or flat)
Thread:
Lists: 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(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

In response to

Responses

pgsql-general by date

Next:From: will trillichDate: 2001-04-27 21:05:56
Subject: Re: last comma inside "CREATE TABLE ()" statements
Previous:From: Vince VielhaberDate: 2001-04-27 20:50:26
Subject: Re: [HACKERS] While we're on the subject of searches...

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