From: | Frank Bax <fbax(at)sympatico(dot)ca> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | steagus(at)yahoo(dot)com (Steagus) |
Subject: | Re: SQL Where LIKE - Range it! |
Date: | 2001-04-27 14:35:37 |
Message-ID: | 3.0.6.32.20010427103537.00ad0d80@pop6.sympatico.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
>
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Burton | 2001-04-27 14:37:41 | Re: SQL Where LIKE - Range it! |
Previous Message | larry a price | 2001-04-27 14:35:36 | Re: Re: Report Writer for PostgreSQL |