I have two table one for users where user save their details as well as zip code and distance(required)
USERTABLE - Name, email, zip, distance.
and another table for zip_info to get latitude and longitude.
ZIPINFO - zipcode, latitude, longitude.
I have user search form where we need to enter zip code and distance. Now the searching result should include all the user whose have zip code is entered zip code, OR they have zip code that are under the radius of entered distance AND also need to check that if user distance radius(it means he will search only under specified distance radius from his zip code) is eligible for search.
Example- a user set his zip code-01960 and distance-50 miles
meaning we want to show this user for zip codes within 50 miles of 01960. So, this user should appear when searching zip code 01960 as well as nearby zipcodes like 01923, 01940 etc.
Now i will explain you in more detail-
User name 'A' set his zip code 134005 and distance - 100 miles (means this user will be search at zip code 134005 and all zip code that are under 100 miles of 134005(e.g 134004).
now I am trying to search a user let suppose Zip code - 134003 and distance is 50 miles. now all the users that are at zip code 134003 and under 50 miles of 134003 should return. Suppose that 134004 is under 50 miles of 134003 but 134005 is not?
According to my requirement user name 'A' should be return.
I want to create SQL query for searching result. Thanx in advance