The article directories
Preface one, the code is as follows
preface
how to quickly calculate the distance between two coordinates in SQL native statement?
One, the code is as follows
code as follows (example) :
$lng=input('longtitude'); //Enter the vertical coordinates
$lat=input('latitude'); //Horizontal coordinates of the input
$distance="ACOS(SIN(( $lat * 3.1415)/180 ) *SIN((latitude * 3.1415)/180 ) +COS(( $lat* 3.1415)/180 ) * COS((latitude * 3.1415)/180 ) *COS(( $lng* 3.1415)/180 - (longtitude * 3.1415)/180 ) ) * 6380";
$fds=Db::table('activity')
->field($distance.' as distance')
->select();