Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2010
    Location
    Florence, MS
    Posts
    486
    Thanks
    10
    Thanked 33 Times in 32 Posts

    Getting closest school by zipcode

    Okay, so I have a database of zipcodes with the following schema:
    <code>
    id,
    longitude,
    latitude,
    </code>
    Then, a list of high schools with the following schema:
    <code>
    id,
    zipcode_id,
    name
    </code>
    I have the query to pull all schools by coordinates(longitude and latitude) with a 30mile radius. But what I am having trouble with is pulling a list of school in a 30 mile radius by inputting a central zipcode. Any ideas, on how I could do this without having two separate queries??
    Notice: If you post a problem and it gets fixed, please remember to go back and place it as solved. ;)
    I always recommend the HEAD First series of books for learning a new coding language. ^_^

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    6,075
    Thanks
    30
    Thanked 834 Times in 832 Posts
    Your database of zipcodes should have a column with the zip codes so entering a zip code yields the long/lat to use for the central point.
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •