-The first Kind
SELECTent_id, Ent_name, longitude, latitude,ROUND( 6378.138 * 2 * ASIN( SQRT(POW (SIN( ( 40.042307 * PI()/ the -Latitude* PI()/ the ) / 2 ), 2 ) + COS(40.042307 * PI()/ the)* COS(Latitude* PI()/ the)*POW (SIN( ( 116.317205 * PI()/ the -Longitude* PI()/ the ) / 2 ), 2 ) ) ) * + ) asJuli fromentORDER byJuliDESCLimit0, -;
--The second type
SELECTent_id, Ent_name, longitude, latitude fromentORDER by POWER(MOD (ABS(Longitude-116.317205), the),2)+ POWER(ABS(Latitude-40.042307),2)DESCLimit0, -;
--according to the latitude and longitude of the upper right corner and the bottom left corner of the enterprise in the range
Selectent_id, Ent_name, longitude, latitude fromentwhere#{toprightlatitude,jdbctype=DECIMAL}>Latitude andLatitude>#{leftlowerlatitude,jdbctype=DECIMAL} and#{toprightlongitude,jdbctype=DECIMAL}>Longitude andLongitude>#{leftlowerlongitude,jdbctype=DECIMAL}
Find nearby businesses based on latitude and longitude | Sql