I have been trying to do a SELECT DISTINCT from a pgsql table and am having
trouble. I've tried subselects, EXISTS, IN, etc, and have had no luck.
I want the query to select all the cities in a state, eliminating
duplicates. I also want the ZIP code (any one of that city's zip codes)
returned in the result set.
select distinct fld_city from tbl_zip_city where fld_state='IA' and
fld_country='us';
That query returns half of what I want (distinct city), but does not return
the associated zip code.
select distinct fld_city, fld_zip from tbl_zip_city where fld_state='IA' and
fld_country='us';
That query does not return distinct cities any more. It returns all cities
(because each city can have several zip codes).
Any suggestions?
Tim
The Des Moines City.net
http://desmoinesnet.com/