Re: SQL Where LIKE - Range it! - Mailing list pgsql-general

From Frank Bax
Subject Re: SQL Where LIKE - Range it!
Date
Msg-id 3.0.6.32.20010427103537.00ad0d80@pop6.sympatico.ca
Whole thread Raw
In response to SQL Where LIKE - Range it!  (steagus@S1PA3M2FIL4TE9Ryahoo.com (Steagus))
List pgsql-general
    select * from table where last_name ~ '^[A-F]';
or
    select * from table where last_name between 'A' and 'G';
or
    select * from table where last_name >='A' and last_name<'G'

The second one is broken if last_name='G' returns something.
Use ~* in first example to ignore case.

Frank

At 08:16 PM 4/26/01 GMT, you wrote:
>H-
>
>I've found the docs on how to select a list of rows from a table were
>all the records have a last name starting with 'W%'.
>select * from table where last_name LIKE 'W%'
>
>What I'd like to do is pull a list of records where there is a range
>of last names; say from A - F.
>select * from table where last_name LIKE 'A%' AND last_name LIKE 'F%'
>- for example.
>
>The above code I've tried for this doesn't seem to work as I'd expect
>it too?
>I've even done
>select * from table where last_name LIKE 'A%' AND LIKE 'F%'
>
>Can anyone provide some details or insights on how to accomplish this?
>
>
>Thanks. Much appreciated.
>-Steagus
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: Have you searched our list archives?
>
>http://www.postgresql.org/search.mpl
>

pgsql-general by date:

Previous
From: "Clayton Vernon"
Date:
Subject: caching/ virtual file systems
Next
From: larry a price
Date:
Subject: Re: Re: Report Writer for PostgreSQL