Re: SQL Where Like - Range it?!

From: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL Where Like - Range it?!
Date: 2001-04-28 02:53:08
Message-ID: 3.0.5.32.20010428105308.00f8a700@192.228.128.13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

At 04:00 PM 27-04-2001 -0500, will trillich wrote:
>On Fri, Apr 27, 2001 at 09:52:26AM -0500, Len Morgan wrote:
>>
>> 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]';

Would the regex query still use a basic text index?

If you're using US-ASCII encoding you could avoid the zzzzs by using a '~'
e.g.
SELECT * FROM table where last_name >='A' and last_name <='F~';

If not use a < 'G' instead of a <=.

Cheerio,
Link.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jack Bates 2001-04-28 03:33:57 On the _need_ to vacuum...
Previous Message Harry Yau 2001-04-28 01:46:44 function with multi-values