Not sure if this is a logic question, or a MySQL question... but, still need help.
I have a list of regions, with coordinates in each one. The database is about 115MB in size. Here's a sampling of the records:
| PC1 | PC2 | CITY | PROV | AREACODE | LAT | LNG |
| A1A | 0B8 | ST. JOHNS | NL | 709 |47.5986880000|-52.7255210000|
| A1A | 0B9 | ST. JOHNS | NL | 709 |47.5505750000|-52.7460720000|
So on, and so forth...
What I need to do, is get the record in each city which represents the maximum latitude and longitude value, then the maximum latitude and minimum longitude value, then the record with the minimum latitudinal value and minimum longitudinal value, then the record with the minimum latitudinal value and the maximum longitudinal value.
What i started out with was:
SELECT MAX(lat), MAX(lng), MIN(lat), MIN(lng), city FROM places GROUP BY city
This gave me ONE record per city, with the MAX/MIN values I asked for, but those min and max represented individual queries for the minimum latitude, maximum latitude, etc... which gave me a pretty good estimation of area so I could draw a polygon over a Google Map... but they're squares, and there's lots of overlap, and I know I can make this better... these results represent the MAXIMUM north, south, east, west of ANY record in group of records of city..
What I want to do, is search for ONE record which has the max latitudinal and max longitudinal value, then the max latitudinal and min longitudinal value, ... etc..
Not sure how to nest these SQL statements... I tried a few IN statements, but always resulted in one record which didn't quite represent any of the max or min values.