Free Teachnology provide free php,mysql,jquery,javascript,
MySQL - when you calculate distance between latitude/longitude its simple way :
Step : 1
create table as per your requirement and two column latitude/longitude with data type Double
Range
On a client project recently, we had to make it easy to filter database query results based on the distance between a user and an entity in our database. It's easy to get overwhelmed in that context, worrying about the crazy amount of PHP calculations you're going to have to run.
MySQL can do that! If you need to calculate this, you can actually get far by just using MySQL!
MySQL 5.7 introduced latitude, which is a native function to calculate the distance between two points.
That’s an interesting start but it doesn’t apply with Geography since the distance between lines of latitude and longitude are not an equal distance apart. As you get closer to the equator,
lines of latitude get further apart. If you use some kind of simple triangulation equation, it may measure distance accurately in one location and terribly wrong in the other,
because of the curvature of the Earth.
Code :
Its very simple to calculate distance between two place using latitude and logitude
MYSQL :
Where condition put as per your table outpout requirment, 10.568047 this is latitude of first column,longitude is 73.8773632 its same place you can put from is table name and having coluse mention that alise varaible value
if you want 3 kilometer then i can put 3 if you want 7KM then put 7
Conclusion :
If you're working in MySQL 5.7+ and provideds find a distances,ways to query aganist,its real world distance.
if you have query let me feedback on mail id : disuzajen@gmail.com
MySQL - when you calculate distance between latitude/longitude its simple way :
Step : 1
create table as per your requirement and two column latitude/longitude with data type Double
On a client project recently, we had to make it easy to filter database query results based on the distance between a user and an entity in our database. It's easy to get overwhelmed in that context, worrying about the crazy amount of PHP calculations you're going to have to run.
MySQL can do that! If you need to calculate this, you can actually get far by just using MySQL!
MySQL 5.7 introduced latitude, which is a native function to calculate the distance between two points.
That’s an interesting start but it doesn’t apply with Geography since the distance between lines of latitude and longitude are not an equal distance apart. As you get closer to the equator,
lines of latitude get further apart. If you use some kind of simple triangulation equation, it may measure distance accurately in one location and terribly wrong in the other,
because of the curvature of the Earth.
Code :
Its very simple to calculate distance between two place using latitude and logitude
MYSQL :
SELECT *,((((acos(sin((10.568047*pi()/180)) * sin((latitude*pi()/180))+cos((10.568047*pi()/180)) * cos((latitude*pi()/180)) * cos(((73.8773632- longitude)*pi()/180))))*180/pi())*60*1.1515*1.609344)) as distance FROM `table_name` HAVING distance<='3'
Where condition put as per your table outpout requirment, 10.568047 this is latitude of first column,longitude is 73.8773632 its same place you can put from is table name and having coluse mention that alise varaible value
if you want 3 kilometer then i can put 3 if you want 7KM then put 7
Conclusion :
If you're working in MySQL 5.7+ and provideds find a distances,ways to query aganist,its real world distance.
if you have query let me feedback on mail id : disuzajen@gmail.com
Comments