Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Thursday, June 16, 2011

Calculate the distance using lattitude, longitude and ZIP codes in MySQL

So, assuming we have a table:

ZIP_CODES
zip_code | lattitude | longitude

We take this zip code from NY
$zip = 10001
$lat = 40.750742
$lon =-74.52976

What we need is the Earth radius (6371 km).

If we need to search the zip codes that are in a 10 km area, we could use this 'small' sintax:

How to calculate age in MySQL

When programming, you hit yourself with many problems, that apparently are very simple, but require a rather difficult syntax.

On a site, i found a small problem - to calculate the age of the person and see if that person is between 2 selected ages.