Re: Pattern Matching - Range of Letters - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: Pattern Matching - Range of Letters
Date
Msg-id 464373F7.40100@commandprompt.com
Whole thread Raw
In response to Pattern Matching - Range of Letters  (Ron St-Pierre <ron.pgsql@shaw.ca>)
List pgsql-general
Ron St-Pierre wrote:
> I'm sure that others have solved this but I can't find anything with my
> (google and archive) searches. I need to retrieve data where the text
> field is within a certain range e.g.
> A-An
> Am-Bc
> Bc-Eg
> ....
> Yi-Zz
>
> Does anyone know of a good approach to achieve this? Should I be looking
> into regular expressions, or maybe converting them to their ascii value
> first?


postgres=# create table test (test text);
CREATE TABLE
postgres=# insert into test values ('A');
INSERT 0 1
postgres=# insert into test values ('b');
INSERT 0 1
postgres=# insert into test values ('c');
INSERT 0 1
postgres=# insert into test values ('d');
INSERT 0 1
postgres=# insert into test values ('e');
INSERT 0 1
postgres=# insert into test values ('Ab');
INSERT 0 1
postgres=# insert into test values ('Ac');
INSERT 0 1
postgres=# insert into test values ('Az');
INSERT 0 1
postgres=# select * from test where test between 'A' and 'An';
  test
------
  A
  Ab
  Ac
(3 rows)



>
> Any comments are appreciated.
>
> postgres 8.2.4, RHEL
>
> Thanks
> Ron St.Pierre
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>


--

       === The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive  PostgreSQL solutions since 1997
              http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL Replication: http://www.commandprompt.com/products/


pgsql-general by date:

Previous
From: Richard Broersma Jr
Date:
Subject: Re: Pattern Matching - Range of Letters
Next
From: "John D. Burger"
Date:
Subject: Re: Pattern Matching - Range of Letters