I have a mysql table full of geo data like so:
locations
- city
- state
- zipcode
- lat
- lon
Since major towns have more than one zip code, there are multiple records for each town.
example:
"city": "BOULDER", "state": "CO", "zipcode": "80310"
"city": "BOULDER", "state": "CO", "zipcode": "80322"
"city": "BOULDER", "state": "CO", "zipcode": "80308"
...
"city": "BOULDER CITY", "state": "NV", "zipcode": "89005"
"city": "BOULDER CITY", "state": "NV", "zipcode": "89006"
I'm creating an autocomplete plugin for my site and so I need to do a query for city='BOULDER', state='CO' and have it only return 1 result for that city, not 3 like it would using the data above.
I tried using group by with .values('city'), but then I only get back the city name, not a dictionary like object of all of my fields (like I need).
Do any of you expert query folks know how I could accomplish this in Django 1.2?