RE: [SQL] SELECT... BETWEEN 'P' and 'Z' - Mailing list pgsql-sql

From Greg Youngblood
Subject RE: [SQL] SELECT... BETWEEN 'P' and 'Z'
Date
Msg-id 2B9713A99045D211BB4E0008C75668692EA7C1@SCORPEXC1.houstoncell.com
Whole thread Raw
List pgsql-sql
Try this:

select distinct on fld_city fld_city, fld_zip from tbl_zip_city where
fld_state = 'IA' and fld_country = 'us' and (substr(fld_city,1,1) between
'P' and 'Z') order by fld_city asc;

That should look at the first letter and return what your looking for.

Greg

Gregory S. Youngblood
ext 2164

-----Original Message-----
Sent: Saturday, January 09, 1999 12:04 PM
Subject: [SQL] SELECT... BETWEEN 'P' and 'Z'

Hello all,

I am trying to query a zip code database and pull all cities in a state in a
range.

According to the SQL tutorial that the pgsql site recommended, using
"between" in your select should be "inclusive". However, my selects are
including the first letter "p" through "y", and excluding "z".

My SQL:

select distinct on fld_city fld_city, fld_zip from tbl_zip_city where
fld_state = 'IA' and fld_country='us' and (fld_city BETWEEN 'P' AND 'Z')
ORDER BY fld_city ASC;

Any suggestions on how I could get the cities that start with "Z" to be
included here (P is included strangely enough)?

pgsql-sql by date:

Previous
From: David Martinez Cuevas
Date:
Subject: Re: [SQL] A path through a tree
Next
From: Bruce Stephens
Date:
Subject: Re: [SQL] A path through a tree