Forum Moderators: open
select distinct(city,zip) from zip where state='CA'
...essentially, I want a list of distinct citys and zips. In otherwords, I only want to see Los Angeles appear once in the list, and I only want one zip code for Los Angeles. Same with San Francisco, etc.
Unfortunately in MySQL I'm being told I can only pass one field to the distinct function. Is there some other way of accomplishing my goal here?
Thanks.
Like you said, its basic SQL - so wouldn't a type-o be pretty self-evident in the above examples?
I think there is something wrong with MySQL 4.1 perhaps? It appears that DISTINCT only worked if I'm only querying for 1 field.
This works:
SELECT DISTINCT location from zip where state='WA'
These do not work:
SELECT DISTINCT(location),zip from zip where state='WA'
SELECT DISTINCT location,zip from zip where state='WA'
... surely this not suppose to behave this way! Am I wrong? Anyone have experience trying to execute such a query on MySQL or version 4.1 in general? Is there a problem or some quirky mysql specific syntax I'm not aware or?
Thanks