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: (view raw, whole thread or download thread mbox)
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.

will(at)serensoft(dot)com -- we need your brain! -- your brain needs us!

In response to


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-2017 The PostgreSQL Global Development Group