Shobbi
Shobbi

Reputation: 947

Finding the Bounds a Location falls in?

I have MySQL database of areas in a city. The attributes of each area are: lat , lng, SWLat, SWLng, NELat, NELng.

I need help in writing a query the tells me the area for a given location, which consists of Lat & Lng.

Thanks in advance, Sal.

Upvotes: 1

Views: 83

Answers (1)

Andrew Leach
Andrew Leach

Reputation: 12983

Not really enough information, but this would appear to fit the bill:

SELECT * FROM table WHERE
myLat >= SWLat AND myLat <= NELat AND
myLng >= SWLng AND myLng <= NELng

myLat and myLng are the coordinates of the location for which you are trying to find the containing region.

Upvotes: 2

Related Questions