Re: Pattern Matching - Range of Letters

From: "John D(dot) Burger" <john(at)mitre(dot)org>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Pattern Matching - Range of Letters
Date: 2007-05-10 19:56:14
Message-ID: 8C9C31DE-1AC6-4E69-9DD1-6CA6D090E084@mitre.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Richard Broersma Jr wrote:
> --- 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
>> ....
>
> 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';

Ron, in case it's not clear, if an index on text_field exists, the
planner can use it to make such queries run relatively fast.

- John D. Burger
MITRE

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mario Munda 2007-05-10 20:00:33 Re: Missing magic block
Previous Message Ron St-Pierre 2007-05-10 19:53:56 Re: Pattern Matching - Range of Letters