Re: Pattern Matching - Range of Letters

From: Ron St-Pierre <ron(dot)pgsql(at)shaw(dot)ca>
To: Ron St-Pierre <ron(dot)pgsql(at)shaw(dot)ca>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Pattern Matching - Range of Letters
Date: 2007-05-10 19:53:56
Message-ID: 46437854.6070700@shaw.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks Richard and Joshua, I had no idea that BETWEEN worked for text.

SELECT *
FROM Your_table AS YT
WHERE YT.text_field BETWEEN 'Aa' AND 'An';

postgres=# select * from test where test between 'A' and 'An';
test
------
A
Ab
Ac
(3 rows)

Ron

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?
>
> 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
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John D. Burger 2007-05-10 19:56:14 Re: Pattern Matching - Range of Letters
Previous Message Joshua D. Drake 2007-05-10 19:35:19 Re: Pattern Matching - Range of Letters