Re: Pattern Matching - Range of Letters

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Ron St-Pierre <ron(dot)pgsql(at)shaw(dot)ca>, pgsql-general(at)postgresql(dot)org
Subject: Re: Pattern Matching - Range of Letters
Date: 2007-05-10 19:33:49
Message-ID: 538480.67730.qm@web31801.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--- Ron St-Pierre <ron(dot)pgsql(at)shaw(dot)ca> 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?

Regular expressions would work, but a between statement should work also.

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2007-05-10 19:35:19 Re: Pattern Matching - Range of Letters
Previous Message Ron St-Pierre 2007-05-10 19:23:11 Pattern Matching - Range of Letters