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
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,598
    Thanks
    24
    Thanked 646 Times in 645 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.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."


  •  

    Posting Permissions

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