查询附近的人SQL

SELECT * FROM member WHERE latitude > '0'-1 AND latitude < '0'+1 AND longitude > '0'-1 
AND longitude < '0'+1

ORDER BY ACOS(SIN(('0' * 3.1415) / 180 ) *SIN((latitude * 3.1415) / 180 ) +COS(('0' * 3.1415) / 180 ) * COS((latitude * 3.1415) / 180 ) *COS(('0'* 3.1415) / 180 - (longitude * 3.1415) / 180 ) ) * 6380 ASC LIMIT 10;
SELECT * FROM member WHERE deleted=0 AND latitude > '%1$s'-1 AND latitude < '%1$s'+1 
AND longitude > '%2$s'-1 

AND longitude < '%2$s'+1 ORDER BY ACOS(SIN(('%1$s' * 3.1415) / 180 ) *SIN((latitude * 3.1415) / 180 )+COS(('%1$s' * 3.1415) / 180 ) * COS((latitude * 3.1415) / 180 ) *COS(('%2$s'* 3.1415) / 180 - (longitude * 3.1415) / 180 ) ) * 6380 ASC LIMIT 5

String where = String.format("deleted=0 AND latitude > '%1$s'-1 AND latitude < '%1$s'+1 
AND longitude > '%2$s'-1 AND 
longitude < '%2$s'+1 ORDER BY ACOS(SIN(('%1$s' * 3.1415) / 180 ) *SIN((latitude * 3.1415) / 180 )+COS(('%1$s' * 3.1415) / 180 ) * COS((latitude * 3.1415) / 180 ) *COS(('%2$s'* 3.1415) / 180 - (longitude * 3.1415) / 180 ) ) * 6380 ASC "
,latitude, longitude);

你可能感兴趣的:(MySQL,CodeBackup)