|
Posted by Andy B on May 19, 2004, 1:31 pm
Please log in for more thread options
rachyett@yahoo.co.uk (Richard Hyett) wrote in message
> Required a means of calulating the distance between a user input UK
> postcode and a series of postcoded records held in a MYSQL database.
> Such that the user can retrieve all resources within a prescribed
> radius of his or her postcode, the SQL statement will pull out all
> resources within 10,20 or 30 miles of where they are depending on
> user selection.
> Any ideas? I'm new to this.
Firstly, congrats on obtaining the postcode data. What you ask is
relatively easy presuming you have a postcode table with matching
coordinates.
1. look up coords of user postcode then 2 or 3.
2. [dumb but quick] select postcodes with an eastings/northings range
of 10, 20, 30 miles and send back the details to the user. this will
form a square and not a radial. use this if this doesn't matter to
much.
3. [trickier] i think you can build a sql query that will do the
pythag on the fly and thus you can limit it to a proper radius. you'll
have to feed it parameters - the user's postcode position, and you
should be away.
|