Determine Users within X Radius by Postcode
I have two database tables:
The first which is a table of postcodes (around 1.7 million records) and has a postcode, longitude and latitude field.
The second which is a table of user data, which includes a postcode field - their postcode on registration.
I need to be able to determine which users fall within X radius of Y (another users postcode) without ideally running a query to compare distances with all 1.7 million postcodes to shortlist possibles.
I was thinking maybe it'd be possible to take Y users postcode and to use their longitude and latitude, doing some math (not my strong point) to determine all possible postcodes - by adjusting the longitude and latitude degrees relative to the distance being searched.
Where to start?